Closed sgoodrow closed 6 years ago
Some notes on why this is needed:
When the component's tableData
is set, the selectedItems
is cleared. In our app, we were interested in preserving the user's selectedItems
when the data is re-set. The re-setting triggers the selected-items-changed
event with a different payload than when user activity changes the selection (with clicks):
e.detail.value
as an array with the new (empty) selectedItems
e.detail.value
with indexSplices
indicating which items were added/removed and what remains.This made it easy to detect when the re-set occurs and use that hook to programmatically assign the selectedItems
to the previous selected items (a cached value) that was not cleared by the component.
However, in single-select mode, the previous selection is being removed (on click) by clearing the selectedItems
array, which makes event handling inconsistent across the two modes. This change normalizes their behavior.
@evanjd I know you have some activity on this repo, if you have a chance to review I would appreciate your thoughtful feedback.
Ran
gulp
# Updated History.md
# Update package.json and bower.json
git ci -m "Bump to <my_new_awesome_version>"
git tag <my_new_awesome_version>
git push
git push --tags
When single-select is being used, the removal of the item from the selectedItems list is triggering the same event logic as when new data is set (clear selectedItems).
This differs from the removal of the item in multi-select, where the deselected item is popped from the list, triggering the splice event flow.
By changing the single-select removal to use the splice event flow instead of the clear event flow, we make the events across single-select and multi-select consistent. Using the selected-item-changed event becomes more consistent across these two selection modes.