ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

Expose click & toggle events for Side Navigation

Open m1trix opened this issue 6 years ago • 6 comments

Is your feature request related to a problem? Please describe. Without click events, regular Angular things like <div routerLink="/"></div> do not work and must be worked around. Also, it is impossible to do something when a <ui5-side-navigation-item> item is collapsed/expanded as no events are fired. In my use case, I want to store the expanded property in the browser's local store, so that it remains the same way after a page refresh. Also, the UX of clicking only the icon of the side bar item is not the greatest.

Describe the solution you'd like

  • Expose the click events for <ui5-side-navigation-item> and <ui5-side-navigation-sub-item>.
  • Expose the toggle (for collapse/expand) events for <ui5-side-navigation-item> in the case, where <ui5-side-navigation-sub-item> exist.
  • Make it possible to cause the collapse/expand by clicking anywhere on the <ui5-side-navigation-item> instead of just the icon. Could be a new property.

Describe alternatives you've considered

  • Manually cause clicks:
<ui5-side-navigation (selection-change)="$event.detail.item.click()">
    <ui5-side-navigation-item routerLink="/"></ui5-side-navigation-item>
</ui5-side-navigation>

Monkey Patches:

this.sideBar //
    .shadowRoot.querySelector('ui5-tree') //
    .shadowRoot.querySelector('ui5-li-tree[icon="course-book"]') //
    .addEventListener('click', () => this.toggleGroup());

Additional context toggles

m1trix avatar Oct 02 '20 14:10 m1trix

Why has such a critical issue moved to the next release, especially that a PR fix has already been provided?

hrstoyanov avatar Nov 16 '20 23:11 hrstoyanov

Hello @hrstoyanov Because we had internal discussions, first the implementations, then about on the naming of the event, and at the end we it was not completed in the previous week. The release was already delayed with 2 weeks and did not want to prolong it further.

BR, ilhan

ilhan007 avatar Nov 17 '20 05:11 ilhan007

We also release "next" (npm tag) versions, basically our master, on regular basis. So once the PR is merged we will release "next" version in npm, that you can consume. Instead of 1.0.0-rc.10 it will look like 0.0.0-commit_hash.

ilhan007 avatar Nov 17 '20 05:11 ilhan007

@ilhan007 I can switch to the "next" version, or continue with the "monkey patching" suggested as workaround in here.

hrstoyanov avatar Nov 17 '20 17:11 hrstoyanov

Hello @hrstoyanov the PR is merged and released in npm under the 0.0.0-e7dd012d7 version. But, you can just use the "next" tag to install it. It includes the requested events and properties in this issue.

One breaking change that you have to be aware and should adopt is related to the icons' usage:

BREAKING CHANGE

icons: refactor(icons): flatten dist directory(#2425) (c84bc8b) Change the distribution path of all individual icons, which changes all icons' public imports, by bringing the icons' modules one level up.

If you previously had: import "@ui5/webcomponents-icons/dist/icons/accept.js";

Now you should remove the icons folder: import "@ui5/webcomponents-icons/dist/accept.js";

BR, ilhan

ilhan007 avatar Nov 25 '20 06:11 ilhan007

Thanks, I will give it a test shortly!

hrstoyanov avatar Nov 25 '20 06:11 hrstoyanov