File tree Expand file tree Collapse file tree 4 files changed +25
-22
lines changed
ui-drilldown/src/Drilldown
ui-top-nav-bar/src/TopNavBar/TopNavBarLayout/SmallViewportLayout Expand file tree Collapse file tree 4 files changed +25
-22
lines changed Original file line number Diff line number Diff line change @@ -1516,7 +1516,9 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
15161516 : this . currentPage . children [ 0 ] ?. props . id
15171517
15181518 if ( ! targetId ) return null
1519- return this . _popover ?. _contentElement ?. querySelector ( `#${ targetId } ` )
1519+ return this . _popover ?. _contentElement ?. querySelector (
1520+ `#${ CSS . escape ( targetId ) } `
1521+ )
15201522 } }
15211523 elementRef = { ( element ) => {
15221524 // setting ref for "Popover" version, the popover root
Original file line number Diff line number Diff line change @@ -291,22 +291,21 @@ class Select extends Component<SelectProps> {
291291 }
292292
293293 scrollToOption ( id ?: string ) {
294- if ( this . _listView ) {
295- const option = this . _listView . querySelector ( `[id="${ id } "]` )
296- if ( ! option ) return
297-
298- const listItem = option . parentNode
299- const parentTop = getBoundingClientRect ( this . _listView ) . top
300- const elemTop = getBoundingClientRect ( listItem ) . top
301- const parentBottom = parentTop + this . _listView . clientHeight
302- const elemBottom =
303- elemTop + ( listItem ? ( listItem as Element ) . clientHeight : 0 )
304-
305- if ( elemBottom > parentBottom ) {
306- this . _listView . scrollTop += elemBottom - parentBottom
307- } else if ( elemTop < parentTop ) {
308- this . _listView . scrollTop -= parentTop - elemTop
309- }
294+ if ( ! this . _listView || ! id ) return
295+ const option = this . _listView . querySelector ( `[id="${ CSS . escape ( id ) } "]` )
296+ if ( ! option ) return
297+
298+ const listItem = option . parentNode
299+ const parentTop = getBoundingClientRect ( this . _listView ) . top
300+ const elemTop = getBoundingClientRect ( listItem ) . top
301+ const parentBottom = parentTop + this . _listView . clientHeight
302+ const elemBottom =
303+ elemTop + ( listItem ? ( listItem as Element ) . clientHeight : 0 )
304+
305+ if ( elemBottom > parentBottom ) {
306+ this . _listView . scrollTop += elemBottom - parentBottom
307+ } else if ( elemTop < parentTop ) {
308+ this . _listView . scrollTop -= parentTop - elemTop
310309 }
311310 }
312311
Original file line number Diff line number Diff line change @@ -331,10 +331,12 @@ class Tabs extends Component<TabsProps, TabsState> {
331331 // this is needed because keypress cancels scrolling. So we have to trigger the scrolling
332332 // one "tick" later than the keypress
333333 setTimeout ( ( ) => {
334- this . state . withTabListOverflow &&
335- this . showActiveTabIfOverlayed (
336- this . _tabList ! . querySelector ( `#tab-${ id } ` )
337- )
334+ if ( this . state . withTabListOverflow ) {
335+ const tab = id
336+ ? this . _tabList ! . querySelector ( `#tab-${ CSS . escape ( id ) } ` )
337+ : null
338+ this . showActiveTabIfOverlayed ( tab )
339+ }
338340 } , 0 )
339341 }
340342
Original file line number Diff line number Diff line change @@ -310,7 +310,7 @@ class TopNavBarSmallViewportLayout extends Component<
310310 setTimeout ( ( ) => {
311311 const container = document . getElementById ( this . _trayContainerId )
312312 const firstOption = container ?. querySelector (
313- `[id="${ targetId } "]`
313+ `[id="${ CSS . escape ( targetId ) } "]`
314314 ) as HTMLSpanElement
315315 firstOption ?. focus ( )
316316 if ( this . _drilldownRef ) {
You can’t perform that action at this time.
0 commit comments