sourcegraph/sourcegraph-public-snapshot

Improve usability of toggle + label elements

開放

#17,133 建立於 2021年1月8日

 (5 則留言) (2 個反應) (0 位負責人)Go (1,374 個分叉)auto 404
accessibilitydesign-debtfrontend-platformgood first issuesourcegraph-refinement-botusabilitywcag/2.1wcag/2.1/fixing

倉庫指標

星標
 (10,290 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Problem

We use the toggle element in a few places in Sourcegraph, sometimes with and sometimes without a label.

With label:

Without label:

When we use the toggle with a label, only the toggle is interactive. Clicking the label doesn't cause the toggle to flip. This feels contrary to best practices for usability and accessibility, particularly in relation to checkbox and radio elements, in which the checkbox or radio should be contained within the label, and clicking the label toggles the element. This improves usability and accessibility by massively increasing the interactive area.

Proposal

We should expand the toggle component to include an optional label, and optional description/helper text, as part of the toggle. Then, that label can be part of the triggering element.

What's clickable today:

What should be clickable:

Additionally, we may want to change the label itself depending on the toggle state. In the above example, the label should change from:

Active Code monitor will watch for the trigger and run actions in response

to:

Inactive Code monitor is not watching for the trigger

Note from Alicja: Please, update the storybook within this issue.

貢獻者指南