Skip to content

fix(ButtonIcon): stop absent pressed from silently enabling toggle mode - #19

Merged
caro3801 merged 3 commits into
mainfrom
fix/button-icon-pressed-default
Aug 28, 2026
Merged

caro3801 merged 3 commits into
mainfrom
fix/button-icon-pressed-default

Conversation

@caro3801

Copy link
Copy Markdown
Collaborator

An unset pressed?: boolean prop with no explicit default falls back to Vue's implicit Boolean-cast (absent -> false), which ButtonIcon forwards straight to BButton. Any boolean pressed puts BButton into toggle-button mode, so it starts managing its own pressed/.active state on every click, independently of the component's own variant, and never flips it back.

Fix: declare pressed: undefined explicitly in ButtonIcon's defaults, opting back out of the implicit cast. Callers that want toggle behavior (e.g. ButtonToggleLock) still pass pressed themselves and are unaffected.

Adds a regression test.

…oggle mode

An optional pressed?: boolean prop with no explicit default gets Vue's
implicit Boolean-cast: absent becomes false instead of staying unset.
ButtonIcon forwards that false straight to BButton, which switches into
toggle-button mode and starts managing its own pressed/.active state on
every click - independently of this component's variant, and it never
flips back. Every ButtonIcon consumer that never intended to be a toggle
button was affected, most visibly ones whose variant is meant to reflect
external state (a click leaves a stale .active class behind).

Declaring pressed: undefined explicitly opts back out of that implicit
cast, so BButton stays a plain button unless a caller passes pressed on
purpose (e.g. ButtonToggleLock).
…ed fix

Lets you click a ButtonIcon whose variant is driven by external state
(the same pattern as datashare-client's ButtonToggle* components) and
confirm in Storybook that it never gets stuck on the active variant.
@caro3801
caro3801 requested a review from a team August 28, 2026 12:36

@pirhoo pirhoo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good!

We did a similar workaround on Datashare: ICIJ/datashare-client#491

@caro3801
caro3801 merged commit 60f4a41 into main Aug 28, 2026
2 checks passed
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.

2 participants