predixdesignsystem / px-data-grid

Predix UI component which defines a data grid
https://www.predix-ui.com/#/elements/px-data-grid
Apache License 2.0
12 stars 20 forks source link

Single-select removal #808

Closed sgoodrow closed 6 years ago

sgoodrow commented 6 years ago

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.

sgoodrow commented 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):

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.

sgoodrow commented 6 years ago

@evanjd I know you have some activity on this repo, if you have a chance to review I would appreciate your thoughtful feedback.

sgoodrow commented 6 years ago

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