Skip to content

Commit

Permalink
fix: listbox crash in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Vasiuro committed Jul 25, 2024
1 parent 97b370b commit 51f7aff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/lib/listbox/ListBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ export const ListBox = React.memo(

const scrollInView = (index = -1) => {
setTimeout(() => {
// As long as this is a timeout - there is not guarantee that listRef will still
// exist by the moment of calling that function. So, if list is already destroyed
// by this moment - do nothing:
if (!listRef.current) return;
const idx = index !== -1 ? `${id.current}_${index}` : focusedOptionId();
const element = listRef.current.querySelector(`li[id="${idx}"]`);

Expand Down

0 comments on commit 51f7aff

Please sign in to comment.