Skip to content

Commit c14a6df

Browse files
avasuroAleksandr Vasiuro
and
Aleksandr Vasiuro
authored
fix: listbox crash in CI (#6925)
Co-authored-by: Aleksandr Vasiuro <[email protected]>
1 parent 97b370b commit c14a6df

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

components/lib/listbox/ListBox.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ export const ListBox = React.memo(
474474

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

0 commit comments

Comments
 (0)