Skip to content

Fleet UI: Dropdown button options don't stay highlighted - #46740

Merged
RachelElysia merged 2 commits into
mainfrom
45853-software-action-dd-highlight
Jun 3, 2026
Merged

Fleet UI: Dropdown button options don't stay highlighted#46740
RachelElysia merged 2 commits into
mainfrom
45853-software-action-dd-highlight

Conversation

@RachelElysia

@RachelElysia RachelElysia commented Jun 3, 2026

Copy link
Copy Markdown
Member

Issue

Closes #45853

Description

  • Software actions dropdown button: Options do not stay highlighted after being clicked
  • Also ensured it was still keyboard accessible

Screenrecording of fix

  • keyboard accessibility + mouse clicks, all don't stay highlighted after clicking
Screen.Recording.2026-06-03.at.12.16.40.PM.mov

Related issue: Resolves #

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • Bug Fixes
    • Button-style dropdowns no longer highlight the previously selected option when reopening; focus styling adjusted so the trigger isn't visually highlighted after close.
  • Tests
    • Added a regression test ensuring reopening a button-style dropdown doesn't retain selection highlighting.
  • Style
    • Updated dropdown button styles to align focus/open visual behavior.

@RachelElysia
RachelElysia requested a review from a team as a code owner June 3, 2026 16:20
Copilot AI review requested due to automatic review settings June 3, 2026 16:20

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.93%. Comparing base (62fa533) to head (8b87b2c).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46740      +/-   ##
==========================================
- Coverage   66.93%   66.93%   -0.01%     
==========================================
  Files        2831     2833       +2     
  Lines      224806   224803       -3     
  Branches    11664    11656       -8     
==========================================
- Hits       150473   150470       -3     
- Misses      60682    60683       +1     
+ Partials    13651    13650       -1     
Flag Coverage Δ
frontend 56.67% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the “Actions” (button-variant) DropdownWrapper behavior where a previously-clicked menu item remains highlighted when reopening the dropdown (reported on Software title details), while preserving keyboard-visible focus styling for accessibility.

Changes:

  • Prevent react-select from persisting a selected option for variant="button" by forcing the controlled value to null.
  • Remove state.isFocused-driven trigger highlighting for the button variant to avoid “stuck” highlighted trigger states after close.
  • Add a button-variant CSS focus-visible treatment and a regression test for the previously-selected highlight.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tsx Clears button-variant selection state and avoids focus-based trigger highlighting that can persist after close.
frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tests.tsx Adds regression coverage for ensuring no option is marked selected after reopen (needs a small robustness tweak).
frontend/components/forms/fields/DropdownWrapper/_styles.scss Adds keyboard focus-visible background styling for the button variant control.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tests.tsx Outdated
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 44afca32-d566-4f6b-8c2d-cbbbfbdeafb5

📥 Commits

Reviewing files that changed from the base of the PR and between 970cd17 and 8b87b2c.

📒 Files selected for processing (1)
  • frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tests.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tests.tsx

Walkthrough

This PR fixes a bug in the DropdownWrapper component's button variant (used by the Actions dropdown) where previously-clicked menu items remained highlighted after the dropdown was reopened. The fix involves three coordinated changes: removing focus-state styling from the button variant, returning null as the selected value to prevent react-select from re-selecting the last item, and adding a button-specific CSS class with corresponding SCSS styling. A regression test validates that the --is-selected marker no longer appears on options after reopening.

Possibly related PRs

  • fleetdm/fleet#45254: Also touches DropdownWrapper selection/highlight behavior and adjusts styling/color logic for isSelected options.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main problem being fixed: dropdown options retaining visual highlighting after being clicked and the dropdown reopened.
Description check ✅ Passed The PR description provides the related issue (#45853), a clear description of the fix, and testing status, but omits the optional Changes file entry and most template checklist items. Core information is present.
Linked Issues check ✅ Passed The code changes directly address issue #45853 by preventing react-select from retaining focus/highlight on previously-selected items when the button variant dropdown reopens, fixing the reported bug where options remained highlighted after being clicked.
Out of Scope Changes check ✅ Passed All changes are strictly scoped to fixing the dropdown highlight issue in DropdownWrapper: a regression test, behavior adjustments to prevent re-highlighting, CSS focus styling, and a class addition for the button variant. No extraneous changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 45853-software-action-dd-highlight

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tests.tsx (1)

152-159: ⚡ Quick win

Assert options are actually rendered to avoid a vacuous pass.

If the reopened menu renders no .react-select__option elements (e.g. menu didn't reopen), forEach runs zero assertions and the test passes without verifying anything. Add a length check so a regression in reopening behavior is also caught.

💚 Proposed guard
-    document
-      .querySelectorAll(".react-select__option")
-      .forEach((option) =>
-        expect(option.className).not.toMatch(/--is-selected/)
-      );
+    const reopenedOptions = document.querySelectorAll(".react-select__option");
+    expect(reopenedOptions.length).toBe(sampleOptions.length);
+    reopenedOptions.forEach((option) =>
+      expect(option.className).not.toMatch(/--is-selected/)
+    );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tests.tsx`
around lines 152 - 159, The test currently checks that reopened menu options do
not have the `--is-selected` class by iterating over
document.querySelectorAll(".react-select__option") but it can vacuously pass
when no options are rendered; update the test in DropdownWrapper.tests.tsx (the
block that queries ".react-select__option") to first assert that the NodeList
length is greater than zero (e.g., expect(options.length).toBeGreaterThan(0))
before running the per-option class assertions so a regression where the menu
fails to reopen will fail the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tests.tsx`:
- Around line 152-159: The test currently checks that reopened menu options do
not have the `--is-selected` class by iterating over
document.querySelectorAll(".react-select__option") but it can vacuously pass
when no options are rendered; update the test in DropdownWrapper.tests.tsx (the
block that queries ".react-select__option") to first assert that the NodeList
length is greater than zero (e.g., expect(options.length).toBeGreaterThan(0))
before running the per-option class assertions so a regression where the menu
fails to reopen will fail the test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 558f3ebd-f0c1-4ec3-86ef-c8afd974358f

📥 Commits

Reviewing files that changed from the base of the PR and between 9f5d31f and 970cd17.

📒 Files selected for processing (3)
  • frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tests.tsx
  • frontend/components/forms/fields/DropdownWrapper/DropdownWrapper.tsx
  • frontend/components/forms/fields/DropdownWrapper/_styles.scss

@RachelElysia
RachelElysia marked this pull request as draft June 3, 2026 17:32
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@RachelElysia
RachelElysia marked this pull request as ready for review June 3, 2026 17:46
@RachelElysia
RachelElysia merged commit 3663475 into main Jun 3, 2026
25 checks passed
@RachelElysia
RachelElysia deleted the 45853-software-action-dd-highlight branch June 3, 2026 19:16
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.

Software title page: Actions dropdown retains highlight on previously-clicked item after reopen

3 participants