Page MenuHomePhabricator

CSS-only ToggleSwitch should respond to clicks on the ToggleSwitch, not just on the label
Closed, ResolvedPublic1 Estimated Story PointsBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

  • Clicking on the labels causes the switches to toggle, but clicking on the toggles themselves does nothing
  • Clicking on the label for the second ("initially on") switch toggles the first switch

What should have happened instead?:
The CSS-only and Vue versions should behave the same: clicking either the labels or the switches should toggle. Clicking the label for a given switch should toggle that switch, not a different one.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 932525 had a related patch set uploaded (by Catrope; author: Catrope):

[design/codex@main] docs, ToggleSwitch: Use unique IDs in CSS-only ToggleSwitch examples

https://gerrit.wikimedia.org/r/932525

The above patch fixes the second part of the bug (the wrong switch toggling), but not the first part (clicking on the toggles does nothing).

Change 932525 merged by jenkins-bot:

[design/codex@main] docs, ToggleSwitch: Use unique IDs in CSS-only ToggleSwitch examples

https://gerrit.wikimedia.org/r/932525

@Catrope after taking a closer look I see what happened here, and have some recommendations.

First: I'd prefer not to wrap the entire thing in a <label> element because that will prevent us from using the Label component internally (see T339013).

This used to work before this patch, which changed the default display of the ToggleSwitch to be flex instead of inline-flex, which means the width of the root element is now 100% the width of its container, not the width of its content. Because of this, the invisible checkbox ends up at the end of the container, not under the switch. Previously, the end of the container was the switch, so it all worked.

To prevent this exact issue from occurring in the Vue component, I wrapped the invisible input and the visible switch in a span and set position: relative on it, so that the right: 0 rule on the input would set it directly on top of the switch. I just failed to do this for the CSS-only version. Lesson learned: we should make sure we're testing the CSS-only versions of components during development and code review!

Given the simplicity of this change (just updating the CSS-only markup examples with this additional span), I'd estimate it at a 1.

Catrope set the point value for this task to 1.Jun 28 2023, 3:12 PM
Catrope moved this task from Needs Refinement to Up Next on the Design-System-Team board.
CCiufo-WMF added a project: Codex 1.0.
AnneT changed the task status from Open to In Progress.Jun 29 2023, 3:01 PM
AnneT claimed this task.
AnneT moved this task from Up Next to Design-Systems-Sprint-2 on the Design-System-Team board.

Change 934367 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[design/codex@main] ToggleSwitch: Fix layout of CSS-only version

https://gerrit.wikimedia.org/r/934367

Change 934367 merged by jenkins-bot:

[design/codex@main] ToggleSwitch: Fix layout of CSS-only version

https://gerrit.wikimedia.org/r/934367

Change 935794 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/core@master] Update Codex from v0.13.0 to v0.14.0

https://gerrit.wikimedia.org/r/935794

Test wiki created on Patch demo by ATomasevich (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/64dc3126c0/w

Change 935794 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v0.13.0 to v0.14.0

https://gerrit.wikimedia.org/r/935794

Test wiki on Patch demo by ATomasevich (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/64dc3126c0/w/