modus-web-components
modus-web-components copied to clipboard
Content Tree: Event trigger on shift arrow keys
Description
Created a function to handle click event using shift + arrow keys
Fixes #1713
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
How Has This Been Tested?
Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
- [x] I have checked my code and corrected any misspellings
Deploy Preview for moduswebcomponents ready!
| Name | Link |
|---|---|
| Latest commit | e5f3ddff93dc08bf7a13a2aad3f0503fc53e2c77 |
| Latest deploy log | https://app.netlify.com/sites/moduswebcomponents/deploys/66c87f2e37aabc000822fcd0 |
| Deploy Preview | https://deploy-preview-2509--moduswebcomponents.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
Lighthouse |
1 paths audited Performance: 25 (🟢 up 1 from production) Accessibility: 98 (no change from production) Best Practices: 92 (no change from production) SEO: 92 (no change from production) PWA: - View the detailed breakdown and full score reports |
To edit notification comments on pull requests, go to your Netlify site configuration.
@prashanthr6383 Can you take a look to make sure that the itemClick event is fired for the correct element when its selected and deselected via the shift arrow keys? If I add a listener to a single element (Social) and i select the item above it first, then do shift down, it doesn't fire the event, but when i unselect it, it does with shift up. It also fires on shift down, which shoudl trigger the item click for the below item, not Social. Double check the arg that is returned as well: True for selected, False for unselected
@prashanthr6383 Can you take a look to make sure that the
itemClickevent is fired for the correct element when its selected and deselected via the shift arrow keys? If I add a listener to a single element (Social) and i select the item above it first, then do shift down, it doesn't fire the event, but when i unselect it, it does with shift up. It also fires on shift down, which shoudl trigger the item click for the below item, not Social. Double check the arg that is returned as well: True for selected, False for unselected
@cjwinsor Updated the code. Now the event trigger for shift up and shift down will return true for selected and false for unselected, but though the itemClick seems to be firing correctly, the selected element is the previous one. Can you confirm if this is the expected behavior of shift + arrow or still needs to be fixed?
https://github.com/trimble-oss/modus-web-components/assets/168108000/f53ef6b6-13ad-4d7a-a897-ec384e941b2c
We will need to discuss. Its acting more like item focus than what I envisioned. We might to consider if this is the right event, or should we have an item selected sorta event. In the recording below, If they start from Personal then shift + down into Work and Social, it works as I would expect. If they shift + up and unselect Social, it fires the event for Work which is now selected. So there is no way to react to the deselecting of Social. In my mind, the user would use this event to see if an item was selected or deselected, but they wouldn't be able to tell Social was deselected with how it is currently. Perhaps trying to work with the concept of itemClick was a misdirection. I'll need to check other libraries.
@cjwinsor I have created a new event emitter, ItemChange. Which seem to fix the problem. Please let me know your thoughts on this.
I see a lot of duplicate events emitted while selecting an option, please check.
Hi, I am not able to reproduce it. looks lie storybook issue kindly re-check
@prashanthr6383 Currently in multiselect mode If I want to implement a behavior based on selection change then I have to listen to both itemClick (tree-view-item) and itemChange (tree-view). Ideally itemChange event at the parent level should be enough and it should be emitted whenever there is a change wrt selection, be it keyboard or mouse click.
After introducing itemChange the itemClick event is not really necessary but lets keep it for backward compatibility and have this documented in the storybook.
