Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nimbleRouterLink cannot be used by wrapper components #2534

Open
rbell517 opened this issue Feb 6, 2025 · 1 comment
Open

nimbleRouterLink cannot be used by wrapper components #2534

rbell517 opened this issue Feb 6, 2025 · 1 comment
Labels
discussion Questions, conversations, or announcements

Comments

@rbell517
Copy link

rbell517 commented Feb 6, 2025

🎙 Discussion

For the SLE details panel we want a Angular router-capable hyperlink details item. To fit in the details panel design, we need a wrapper component that adds some styling and a label. To be router-capable, nimble provides the nimbleRouterLink, which is a derivation of the Angular routerLink. Ideally for our wrapper component we provide just as much flexibility that the nimbleRouterLink provides. To do that today we would need to copy forward all of the inputs available on a routerLink, which isn't ideal.

nimbleRouterLink's selector is specifically keyed to nimble-anchor elements. It won't bind to a wrapper div or wrapper Angular component. From looking at the implementation, this is because the nimbleRouterLink implementation relies on the directive being directly attached to the nimble-anchor so it can update its href attribute whenever inputs to the directive are changed (via ngOnChanges). nimbleRouterLink also hooks into the onClick handler to disable standard anchor navigation.

I'm opening this as a discussion and not as a bug because this is clearly intended behavior with the current implementation, but I'd like to discuss what it would take to allow what I'd like to do.

@rbell517 rbell517 added discussion Questions, conversations, or announcements triage New issue that needs to be reviewed labels Feb 6, 2025
@m-akinc m-akinc removed the triage New issue that needs to be reviewed label Feb 6, 2025
@mollykreis
Copy link
Contributor

mollykreis commented Feb 7, 2025

After a bit of discussion, we don't think that trying to put nimbleRouterLink on a wrapper component is the correct path forward. Specifically, the issue is that the routerLink (which nimbleRouterLink extends) not only has all the inputs to make navigation work correctly, but it also contains the onClick behavior to control interaction with the link. It is intended to be used on a component that is entirely a link, which is not the case for the component you are describing -- which would have a link + label, where clicking the label should cause page navigation.

That being said, we have two alternatives to suggest:

Alternative 1 - Use Angular's content projection to "slot" the nimble-link into the component

Alternative 2 - Duplicate the desired inputs on the component

  • You could just duplicate the desired inputs on the component and set them on the underlying nimble-anchor. Depending on what the use cases are for the component, not all the inputs from the routerLink would need to be duplicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions, conversations, or announcements
Projects
Status: Backlog
Development

No branches or pull requests

3 participants