mpetuska/kmdc

[kmdc-select] throws "Uncaught TypeError: Cannot read properties of undefined (reading 'length')"

prykhodev opened this issue · 1 comments

In the following code button click triggers recomposition of Menu element

val items = remember { mutableStateListOf("item1") }
MDCSelect {
    Anchor("Items")
    Menu { items.forEach { SelectItem(it) } }
}
MDCButton("Add item") {
    onClick { items.add("item${items.size + 1}") }
}

and clicking on newly created item throws errors:

Uncaught TypeError: Cannot read properties of undefined (reading 'length')
    at MDCSelectFoundation.layout (foundation.ts?cd83:213:45)
    at MDCSelectFoundation.handleChange (foundation.ts?cd83:264:10)
    at MDCSelectFoundation.setSelectedIndex (foundation.ts?cd83:146:12)
    at MDCSelectFoundation.handleMenuItemAction (foundation.ts?cd83:274:10)
    at HTMLDivElement.handleMenuItemAction (component.ts?327b:148:23)
    at MDCComponent.emit (component.ts?327b:116:15)
    at Object.notifySelected (component.ts?327b:341:14)
    at MDCMenuFoundation.handleItemAction (foundation.ts?cd83:98:18)
    at HTMLDivElement.handleItemAction (component.ts?327b:85:23)
    at MDCComponent.emit (component.ts?327b:116:15)
Uncaught TypeError: Cannot read properties of undefined (reading 'length')
    at MDCSelectFoundation.layout (foundation.ts?cd83:213:45)
    at MDCSelectFoundation.handleFocus (foundation.ts?cd83:282:10)
    at HTMLDivElement.handleFocus (component.ts?327b:135:23)
    at Object.restoreFocus (component.ts?327b:182:32)
    at eval (foundation.ts?cd83:651:22)

This errors is thrown even if i'm triggering recomposition of MDCSelect too

Thanks for the bug report!