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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

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 a function as @currentWhen to 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
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