modus-web-components icon indicating copy to clipboard operation
modus-web-components copied to clipboard

Content Tree: Event trigger on shift arrow keys

Open prashanthr6383 opened this issue 1 year ago • 6 comments

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

prashanthr6383 avatar May 08 '24 14:05 prashanthr6383

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...

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.

netlify[bot] avatar May 08 '24 14:05 netlify[bot]

@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

cjwinsor avatar May 16 '24 14:05 cjwinsor

@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

@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

prashanthr6383 avatar May 20 '24 14:05 prashanthr6383

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.

selectiontest

cjwinsor avatar Jul 12 '24 17:07 cjwinsor

@cjwinsor I have created a new event emitter, ItemChange. Which seem to fix the problem. Please let me know your thoughts on this.

prashanthr6383 avatar Jul 18 '24 15:07 prashanthr6383

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 avatar Aug 09 '24 13:08 prashanthr6383

@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.

prashanth-offcl avatar Aug 19 '24 13:08 prashanth-offcl