Repository navigation
fix(ButtonIcon): stop absent pressed from silently enabling toggle mode - #19
Merged
Merged
Conversation
…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.
…he pressed fix" This reverts commit c2de126.
pirhoo
approved these changes
Aug 28, 2026
Member
There was a problem hiding this comment.
Good!
We did a similar workaround on Datashare: ICIJ/datashare-client#491
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An unset
pressed?: booleanprop with no explicit default falls back to Vue's implicit Boolean-cast (absent ->false), whichButtonIconforwards straight toBButton. Any booleanpressedputsBButtoninto toggle-button mode, so it starts managing its ownpressed/.activestate on every click, independently of the component's ownvariant, and never flips it back.Fix: declare
pressed: undefinedexplicitly inButtonIcon's defaults, opting back out of the implicit cast. Callers that want toggle behavior (e.g.ButtonToggleLock) still passpressedthemselves and are unaffected.Adds a regression test.