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

feat(command): allow items to be dynamically selected #402

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

Conversation

stewones
Copy link
Contributor

@stewones stewones commented Oct 16, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • accordion
  • alert
  • alert-dialog
  • aspect-ratio
  • avatar
  • badge
  • button
  • calendar
  • card
  • checkbox
  • collapsible
  • combobox
  • command
  • context-menu
  • data-table
  • date-picker
  • dialog
  • dropdown-menu
  • hover-card
  • icon
  • input
  • label
  • menubar
  • navigation-menu
  • pagination
  • popover
  • progress
  • radio-group
  • scroll-area
  • select
  • separator
  • sheet
  • skeleton
  • slider
  • sonner
  • spinner
  • switch
  • table
  • tabs
  • textarea
  • toast
  • toggle
  • tooltip
  • typography

What is the current behavior?

currently, there's no way to tell if a command item is aria-selected. so the problem is that the first item will always look like this:

Screenshot 2024-10-16 at 19 27 53

What is the new behavior?

after this PR it would look like this:

Screenshot 2024-10-16 at 19 28 58

  <brn-cmd-list hlm>
    <brn-cmd-group hlm>
       @for (item of items(); track $index) {
         <button
              hlm
              brnCmdItem
              [selected]="currentItem() === item"
            >

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@stewones
Copy link
Contributor Author

is the ci/prettier something I can fix? cause locally ci.format-sort says there's no fix to apply.

@stewones stewones marked this pull request as draft October 16, 2024 23:11
@stewones
Copy link
Contributor Author

I realized there must be a bug with the cmdk lib, theoretically to achieve what I want here a simple class cmdk-item-active should be enough but I have no idea why it doesn't work.

@stewones stewones marked this pull request as ready for review October 16, 2024 23:49
@stewones
Copy link
Contributor Author

stewones commented Oct 16, 2024

ended up with a simpler solution, I tried to avoid this change but looks like setting aria-selected on the host only has no effect.

The final result looks like this, I wish we could get rid of the first item always being aria-selected no matter what, but can't see a way out of this without breaking the keyboard navigation (cmdk)

Screen.Recording.2024-10-16.at.20.46.03.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant