Hello, we are currently working on binding Material UI components to the Halogen components.
Basically, for each component we create a component in Halogen, handling initialization in Initialize
action, and destruction in Finalize
action, according to the component lifecycle.
So everything went smooth until we wanted to bind to data tables FFI (Material Design). We instantiate an MDCDataTable
component from the root element referenced by a RefLabel
and return it back from the FFI for later calls. And everything works just fine, animations, selection events, highlighting, etc… Until we change contents of a table.
The specification says to call layout()
when we add or remove row checkboxes, so that the MDC code can reinitialize event handlers, destroy old ones and so on. Adding new rows is not a problem - when we modify a component state so that new rows are rendered, calling foreign layout()
afterwards works just fine. All takes a bad turn, when we modify a state so that rows are removed, and then try to layout (even when we remove only rows added before). We get a runtime error
Uncaught Error: Checkbox component requires a .mdc-checkbox__native-control element (…)
It seems that it errors during layout, when it tries do destroy previously-registered row checkboxes. That is weird, because it does the same during finalize, and we never get errors during finalization. What is more weird, when we tried to debug the error, it seems that foreign code actually does find a component with no native-control element:
<div class="mdc-checkbox mdc-data-table__row-checkbox mdc-checkbox--upgraded" style></div>
But we never create such checkbox elements (no style, no children)! It looks as if Halogen removed part of the DOM referenced in a foreign code (all its children). After the error is raised, we cannot find such an element on page (it does not exist), so it looks like foreign code did not keep up with the changes.
Again, sorry for not giving any more context and any specific example, but maybe something would ring a bell. Perhaps it is a simple mistake, but I’m not familiar at all with Halogen internals.