@@ -828,11 +828,13 @@ class ClassHelper extends HTMLElement {
828828 row . classList . add ( "row-style" ) ;
829829
830830 if ( includeCheckbox ) {
831+ const td = document . createElement ( 'td' ) ;
831832 const checkbox = document . createElement ( "input" ) ;
832833 checkbox . setAttribute ( "type" , "checkbox" ) ;
833834 checkbox . checked = false ;
834835 checkbox . setAttribute ( "tabindex" , - 1 ) ;
835- row . appendChild ( checkbox ) ;
836+ td . appendChild ( checkbox )
837+ row . appendChild ( td ) ;
836838 if ( preSelectedValues . includes ( entry [ headers [ 0 ] ] ) ) {
837839 checkbox . checked = true ;
838840 }
@@ -849,16 +851,21 @@ class ClassHelper extends HTMLElement {
849851 if ( includeCheckbox ) {
850852 tbody . addEventListener ( "click" , ( e ) => {
851853 let id , tr ;
852- if ( e . target . tagName === "INPUT" || e . target . tagName === "TD" ) {
854+ if ( e . target . tagName === "INPUT" ) {
855+ tr = e . target . parentElement . parentElement ;
856+ id = tr . dataset . id ;
857+ } else if ( e . target . tagName === "TD" ) {
853858 id = e . target . parentElement . dataset . id ;
854859 tr = e . target . parentElement ;
855860 } else if ( e . target . tagName === "TR" ) {
856861 id = e . target . dataset . id ;
857862 tr = e . target ;
858863 }
859864
860- if ( e . target . tagName !== "INPUT" ) {
861- tr . children . item ( 0 ) . checked = ! tr . children . item ( 0 ) . checked ;
865+ if ( e . target . tagName !== "INPUT" ) {
866+ /* checkbox is only child of the first td of the table row */
867+ let checkbox = tr . children . item ( 0 ) . children . item ( 0 ) ;
868+ checkbox . checked = ! checkbox . checked ;
862869 }
863870
864871 this . dispatchEvent ( new CustomEvent ( "selection" , {
@@ -1074,7 +1081,8 @@ class ClassHelper extends HTMLElement {
10741081 if ( e . target . tagName == "TR" && e . shiftKey == false ) {
10751082 e . preventDefault ( ) ;
10761083 let tr = e . target ;
1077- tr . children . item ( 0 ) . checked = ! tr . children . item ( 0 ) . checked ;
1084+ let checkbox = tr . children . item ( 0 ) . children . item ( 0 )
1085+ checkbox . checked = ! checkbox . checked ;
10781086 this . dispatchEvent ( new CustomEvent ( "selection" , {
10791087 detail : {
10801088 value : tr . dataset . id
@@ -1091,7 +1099,8 @@ class ClassHelper extends HTMLElement {
10911099 if ( e . target . tagName == "TR" && e . shiftKey == false ) {
10921100 e . preventDefault ( ) ;
10931101 let tr = e . target ;
1094- tr . children . item ( 0 ) . checked = ! tr . children . item ( 0 ) . checked ;
1102+ let checkbox = tr . children . item ( 0 ) . children . item ( 0 )
1103+ checkbox . checked = ! checkbox . checked ;
10951104 this . dispatchEvent ( new CustomEvent ( "selection" , {
10961105 detail : {
10971106 value : tr . dataset . id
0 commit comments