Skip to content

Commit

Permalink
fix(tree-select): fix item interface doesn't sync with values (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theeraphat-Sorasetsakul committed Aug 21, 2024
1 parent 7b8d10d commit 543e0cf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions packages/elements/src/tree-select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,29 @@ export class TreeSelect extends ComboBox<TreeSelectDataItem> {
}
}

/**
* Update composer values.
* @param newValues new values
* @returns {void}
*/
protected override updateComposerValues(newValues: string[]): void {
for (const item of this.treeManager.checkedItems) {
this.treeManager.uncheckItem(item);
}
const selectedItems = this.queryItems((item, composer) => {
return newValues.includes(composer.getItemPropertyValue(item, 'value') ?? '');
});
const sortedSelectedItem = [];
for (const item of selectedItems) {
const value = this.composer.getItemPropertyValue(item, 'value') ?? '';
const index = newValues.indexOf(value);
sortedSelectedItem[index] = item;
}
for (const item of sortedSelectedItem) {
this.treeManager.checkItem(item);
}
}

/**
* Renderer used to render tree item elements
*/
Expand Down

0 comments on commit 543e0cf

Please sign in to comment.