Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(framework): reliably re-render lists of DOM nodes #1519

Merged
merged 2 commits into from
Apr 28, 2020

Conversation

vladitasev
Copy link
Contributor

In the lit-html repeat directive, the key function is defined as follows:
export type KeyFn<T> = (item: T, index: number) => unknown;
It takes 2 arguments: item and index and the usage is as follows:
newKeys[index] = keyFn ? keyFn(item, index) : index;

We pass undefined to our repeat in litVisitor class. Therefore lit-html takes the index as key.
The purpose of this change is to pass the _id, which is unique to every UI5 Web Component, and the index as fallback, so that the algorithm works as before when there are no _ids (f.e. when we don't iterate on arrays of UI5 Web Components).

This will optimize the rerendering of lists of UI5 Web Comopnents and also prevent some bugs, such as the filtering of items in ui5-multi-combobox.

fixes: #1487

ilhan007
ilhan007 previously approved these changes Apr 24, 2020
@vladitasev vladitasev merged commit 9edb5de into master Apr 28, 2020
@vladitasev vladitasev deleted the smarter-key-function-lithtml branch April 28, 2020 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui5-multi-combobox: shows wrong selection when selecting item via whitespace
3 participants