Skip to content

DEV: allows to pass @currentWhen to NavItem #32825

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

Merged
merged 5 commits into from
May 21, 2025
Merged

Conversation

jjaffeux
Copy link
Contributor

@jjaffeux jjaffeux commented May 20, 2025

Some cases are more complex than the default behavior of this.router.isActive(this.args.route), in this case you can give use @currentWhen on your NavItem component.

Example:

get isItCurrent() {
  return true;
}

<template>
  <NavItem @i18nLabel="test" @currentWhen={{this.isItCurrent}} />
</template>

<template>
  <NavItem @i18nLabel="test" @currentWhen="foo" />
</template>

<template>
  <NavItem @i18nLabel="test" @currentWhen="foo.show foo.index" />
</template>

No test as I can't write a component test for this as it relies on the router.

Some cases are more complex than the default behavior of `this.router.isActive(this.args.route)`, in this case you can give a function as `@currentWhen` to your `NavItem` component.

Example:

```
@action
isItCurrent(route) {
  return true;
}

<template>
  <NavItem @i18nLabel="test" @currentWhen={{this.isItCurrent}} />
</template>
```

No test as I can't write a component test for this as it relies on the router.
@jjaffeux jjaffeux requested a review from davidtaylorhq May 20, 2025 22:00
@jjaffeux jjaffeux merged commit 02bc561 into main May 21, 2025
17 checks passed
@jjaffeux jjaffeux deleted the nav-item-current-when branch May 21, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants