@@ -55,6 +55,9 @@ const INNER_STYLE = {
55
55
minWidth : '100%'
56
56
} ;
57
57
58
+ const columnSelector = ( column_id : string ) =>
59
+ `[data-dash-column="${ CSS . escape ( column_id ) } "]:not(.phantom-cell)` ;
60
+
58
61
export default class ControlledTable extends PureComponent < ControlledTableProps > {
59
62
private readonly menuRef = React . createRef < HTMLDivElement > ( ) ;
60
63
private readonly stylesheet : Stylesheet = new Stylesheet (
@@ -176,12 +179,9 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
176
179
( active . column_id !== active_cell ?. column_id ||
177
180
active . row !== active_cell ?. row )
178
181
) {
182
+ const { column_id, row} = active_cell ;
179
183
const target = this . $el . querySelector (
180
- `td[data-dash-row="${
181
- active_cell . row
182
- } "][data-dash-column="${ CSS . escape (
183
- active_cell . column_id
184
- ) } "]:not(.phantom-cell)`
184
+ `td[data-dash-row="${ row } "]${ columnSelector ( column_id ) } `
185
185
) as HTMLElement ;
186
186
if ( target ) {
187
187
target . focus ( ) ;
@@ -1170,19 +1170,11 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
1170
1170
const { table, tooltip : t } = this . refs as { [ key : string ] : any } ;
1171
1171
1172
1172
if ( t ) {
1173
- const cell = header
1174
- ? table . querySelector (
1175
- `tr:nth-of-type(${
1176
- row + 1
1177
- } ) th[data-dash-column="${ CSS . escape (
1178
- id
1179
- ) } "]:not(.phantom-cell)`
1180
- )
1181
- : table . querySelector (
1182
- `td[data-dash-column="${ CSS . escape (
1183
- id
1184
- ) } "][data-dash-row="${ row } "]:not(.phantom-cell)`
1185
- ) ;
1173
+ const cell = table . querySelector (
1174
+ header
1175
+ ? `tr:nth-of-type(${ row + 1 } ) th${ columnSelector ( id ) } `
1176
+ : `td[data-dash-row="${ row } "]${ columnSelector ( id ) } `
1177
+ ) ;
1186
1178
1187
1179
( this . refs . tooltip as TableTooltip ) . updateBounds ( cell ) ;
1188
1180
}
0 commit comments