Skip to content

Commit a72ee10

Browse files
committed
fix: work around list foundation using setTimeout before accessing the adapter
1 parent c6cef15 commit a72ee10

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/list/List.svelte

+10-2
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,17 @@
167167
return (listItem?.hasCheckbox && listItem.checked) ?? false;
168168
},
169169
isFocusInsideList: () =>
170+
element != null &&
170171
getElement() !== document.activeElement &&
171172
getElement().contains(document.activeElement),
172-
isRootFocused: () => document.activeElement === getElement(),
173+
isRootFocused: () =>
174+
element != null && document.activeElement === getElement(),
173175
listItemAtIndexHasClass,
174176
notifyAction: (index) => {
175177
selectedIndex = index;
176-
dispatch(getElement(), 'MDCList:action', { index });
178+
if (element != null) {
179+
dispatch(getElement(), 'MDCList:action', { index });
180+
}
177181
},
178182
removeClassForElementIndex,
179183
setAttributeForElementIndex,
@@ -270,6 +274,10 @@
270274
}
271275
272276
function getOrderedList() {
277+
if (element == null) {
278+
return [];
279+
}
280+
273281
return [...getElement().children]
274282
.map((element) => itemAccessorMap.get(element))
275283
.filter(

0 commit comments

Comments
 (0)