Skip to content

fix(select): use Select.Label + Field hideLabel to fix hover coupling#502

Merged
mattrothenberg merged 3 commits intomainfrom
feat/field-hide-label
May 8, 2026
Merged

fix(select): use Select.Label + Field hideLabel to fix hover coupling#502
mattrothenberg merged 3 commits intomainfrom
feat/field-hide-label

Conversation

@mattrothenberg
Copy link
Copy Markdown
Collaborator

@mattrothenberg mattrothenberg commented May 8, 2026

Summary

Alternative approach to #500 for fixing the Select label hover/focus coupling bug.

Instead of inlining Field's description/error logic into Select (~50 lines of duplicated wiring), this PR:

  • Adds hideLabel prop to Field — renders layout, description, and error but skips the native <label> element. This is a general-purpose escape hatch for any component that provides its own accessible label.

  • Renders Select.Label inside SelectBase.Root — Base UI handles accessible naming via context, no manual aria-labelledby wiring needed.

  • Passes hideLabel to Field — description/error/layout stay in Field where they belong.

  • Reviews

  • bonk has reviewed the change

  • automated review not possible because: needs visual review of hover behavior

  • Tests

  • Additional testing not necessary because: no API changes, existing tests pass

Native <label> elements couple hover/focus to their associated control,
causing the Select trigger to change appearance when hovering the label
text. Fix by:

1. Adding hideLabel prop to Field — renders layout, description, and
   error but skips the <label> element
2. Rendering Base UI Select.Label inside SelectBase.Root for accessible
   naming without hover coupling
3. Passing hideLabel to Field so description/error stay in Field where
   they belong (no inlined Field logic)

This is an alternative to #500 that avoids duplicating Field internals.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 8, 2026

npm i https://pkg.pr.new/@cloudflare/kumo@502

commit: 1e19f46

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Docs Preview

View docs preview

Commit: 8c8d918

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Visual Regression Report — 5 changed, 11 unchanged

5 screenshot(s) with visual changes:

Select / Select Sizes

170 px (0.09%) changed

Before After Diff
Before After Diff

Select / Select With Field

635 px (0.54%) changed

Before After Diff
Before After Diff

Select / Select Loading

0 px (0%) changed

Before After Diff
Before After Diff

Select / Select Long List

1,346 px (1.14%) changed

Before After Diff
Before After Diff

Select (Open)

252 px (0%) changed

Before After Diff
Before After Diff
11 screenshot(s) unchanged
  • Select / Select Basic
  • Select / Select Without Label
  • Select / Select Placeholder
  • Select / Select With Tooltip
  • Select / Select Custom Rendering
  • Select / Select Multiple
  • Select / Select Complex
  • Select / Select Disabled Options
  • Select / Select Disabled Items
  • Select / Select Grouped
  • Select / Select Grouped With Disabled

Generated by Kumo Visual Regression

@mattrothenberg
Copy link
Copy Markdown
Collaborator Author

/bonk approve

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

bonk approves - Clean, minimal fix that avoids code duplication while solving the hover/focus coupling issue. The hideLabel prop is a nice general-purpose addition to Field that other components can use when they need to provide their own accessible labels. Using Base UI's Select.Label with hideLabel is much cleaner than inlining Field's logic into Select. Visual diff changes are expected since the label structure changed (native label to Base UI's Select.Label).

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 8, 2026

Approved PR #502

Clean, minimal fix that solves the hover/focus coupling bug without duplicating code. The hideLabel prop is a smart general-purpose addition to Field, and using Base UI's Select.Label keeps the accessible naming handled via context rather than manual aria-labelledby wiring.

github run

The label text lost its styles (text-base font-medium text-kumo-default)
when we moved from Field rendering the label to SelectBase.Label with
className="contents". Apply the styles directly to SelectBase.Label.
@mattrothenberg mattrothenberg merged commit 8d43b8b into main May 8, 2026
16 checks passed
@mattrothenberg mattrothenberg deleted the feat/field-hide-label branch May 8, 2026 17:33
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.

1 participant