Skip to content

fix: mp-3213-center the switch knob on the track when the label wraps - #904

Merged
infante-jaime merged 1 commit into
mainfrom
fix/mp-3213-kv-switch-knob-centering
Sep 15, 2026
Merged

infante-jaime merged 1 commit into
mainfrom
fix/mp-3213-kv-switch-knob-centering

Conversation

@infante-jaime

@infante-jaime infante-jaime commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

MP-3213 — Center the switch knob when the label wraps

Fixes https://kiva.atlassian.net/browse/MP-3213

At mobile widths, a KvSwitch label that wraps to multiple lines made the
row taller than the track, and the knob — anchored to the top of the row —
drifted off the track.

Changes

  • Anchor the knob to the vertical center (tw-top-1/2 -tw-translate-y-1/2)
    instead of tw-top-0, so it stays centered on the track at any label height.
  • Add a wrapped-label example to the Forms/KvSwitch Small story to show the case.
  • Add a unit test asserting the centering classes.

Testing

  • npm run test — all KvSwitch specs pass, including the new centering test.
  • Verified in Storybook with the wrapped-label example at ~320px width.

In the Storybook, we deliberately added a second toggle with a short label so that it needs to be centered by the fix.

image

@infante-jaime
infante-jaime requested a review from a team September 14, 2026 23:41
@dyersituations

Copy link
Copy Markdown
Collaborator

@infante-jaime please post a screenshot of the fixed switch to the description of the PR.

@roger-in-kiva roger-in-kiva left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a case with more than 2 lines?

@infante-jaime

Copy link
Copy Markdown
Contributor Author

Is there a case with more than 2 lines?

Yes — the fix works regardless of the number of lines. The track and knob are both centered against the same row, so they stay aligned at any label height.

I also verified it with a 10-line label. The story just uses 2 lines to keep the example simple.

@infante-jaime
infante-jaime merged commit 4fe5e04 into main Sep 15, 2026
5 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.

3 participants