fix: ButtonSecondary disabled-state outline in dark mode#1168
Conversation
In dark mode, the disabled `ButtonSecondary` blends into the page background and reads as floating text. Add a 1px `border-default` outline to the disabled state when the active theme is dark, leaving light-mode rendering and all non-disabled states unchanged.
Adds two cases in `ButtonSecondary.test.tsx` to keep the package at
100% branch coverage after introducing the dark-mode disabled outline:
- default + `isDisabled` under `Theme.Dark` → border resolves to
`border-default` from a dark-themed tailwind instance.
- default + `isDisabled` under the implicit light theme → border stays
`border-transparent`.
Introduces a small `expectBorderColor` helper mirroring
`expectBackground` and a `twDark` instance produced via `renderHook`
wrapped in `<ThemeProvider theme={Theme.Dark}>`.
Adds a trailing `expect(btn).toBeDefined()` to the two new dark-mode disabled-border tests so they match the existing pattern in this file and pass the `jest/expect-expect` lint rule, which does not recognise the `expectBorderColor`/`expectBackground` helpers as assertion sites.
There was a problem hiding this comment.
Hey @Kureev, thanks for the contribution. Can you also make this update to the design-system-react version of ButtonSecondary?
I think we should also check whether we can keep the same border color for the enabled state as well as in light mode. That would reduce a lot of the complexity here.
A couple of questions:
- Should the border only exist when the button is disabled?
- Can we use the same border color in light mode to reduce complexity?
@amandaye0h can you help advice here? IMO I think the border should exist in light mode disabled as well to reduce complexity |
Description
In dark mode, the disabled
ButtonSecondary(default variant) blends into the page background and reads as floating text rather than a control. This adds a 1pxborder-defaultoutline to the disabled state when the active theme is dark. Light mode, all non-disabled states, and theisDanger/isInverse/isInverse + isDangersub-variants are unchanged.Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-783
Manual testing steps
ButtonSecondary).ButtonSecondarywithisDisabled={true}(e.g. theisDisabledstory underButtonSecondary).border-defaulttoken, distinct from the page background.ButtonSecondaryis unchanged (no visible outline).isDanger/isInverse/isInverse + isDangersub-variants render exactly as before.Screenshots/Recordings
BEFORE

AFTER

Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Low risk styling change limited to
ButtonSecondary’s disabled default state in dark mode, with added unit tests to lock behavior. No behavioral, data, or security-sensitive logic is affected.Overview
Fixes the disabled default
ButtonSecondaryappearance in dark mode by applying aborder-defaultoutline whenisDisabledand the active theme isTheme.Dark(light mode and other sub-variants keep their existing borders).Updates tests to be theme-aware via
ThemeProvider, adds a helper to assertborderColor, and covers both dark-mode outlined and light-mode transparent disabled borders.Reviewed by Cursor Bugbot for commit 2f6c455. Bugbot is set up for automated code reviews on this repo. Configure here.