Skip to content

Match controls disabled by an ancestor fieldset - #1913

Open
feritcemkahraman wants to merge 2 commits into
fb55:masterfrom
feritcemkahraman:fix-disabled-fieldset-controls
Open

feritcemkahraman wants to merge 2 commits into
fb55:masterfrom
feritcemkahraman:fix-disabled-fieldset-controls

Conversation

@feritcemkahraman

@feritcemkahraman feritcemkahraman commented Oct 13, 2026 •

Copy link
Copy Markdown

For <fieldset disabled><input></fieldset>, :disabled currently matches only the fieldset and :enabled matches the input. Apply fieldset inheritance outside each ancestor's first direct legend, including when the disabled ancestor is above the query root. Custom pseudo aliases keep their existing context behavior.

Options and optgroups also inherit their select's disabled state, as specified by the current HTML Standard. The installed Chromium differs for this case, so those expectations follow the standard.

Regressions were verified before their respective fixes. All 227 tests pass (one existing skip); ESLint, TypeScript, build, and changed-file Biome pass. Full Biome has existing CRLF formatting failures. Tests cover nested legends, explicit disabled states, scoped queries, and custom aliases. Firefox, WebKit, and benchmarks were not run.

Summary by CodeRabbit

  • Bug Fixes
    • Updated :disabled matching to account for disabled fieldsets and their supported form controls, including nested fieldsets, select options, and optgroups. Controls inside the first direct legend remain exempt from inherited disabled state, while explicitly disabled fieldsets are still matched.
    • Improved :enabled matching for options and ensured disabled-state results remain consistent in scoped queries and element checks.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T15:23:38.615809Z 95cc9e3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 450cc200-36ed-4096-91cb-c0c1c66484d1
📥 Commits

Reviewing files that changed from the base of the PR and between f8e728e and 95cc9e3.

📒 Files selected for processing (3)
  • src/pseudo-selectors/aliases.ts
  • src/pseudo-selectors/index.ts
  • test/pseudo-classes.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The disabled alias now matches disabled fieldsets and supported controls within them, except controls inside the first direct legend. It also matches options and optgroups disabled by selects or fieldsets. Built-in alias compilation uses different context options. Tests cover scoped queries and :enabled matching.

Changes: Disabled fieldset matching

Layer / File(s) Summary
Disabled alias matching and validation
src/pseudo-selectors/aliases.ts, src/pseudo-selectors/index.ts, test/pseudo-classes.ts
The alias matches disabled fieldsets and supported descendants, including options and optgroups. Controls inside the first direct legend are exempt. Built-in :disabled compilation uses relativeSelector: false and no search context. Tests cover nested fieldsets, scoped queries, and :enabled matching.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: fb55

Merge Risk: ⚪ Minimal · up to 95cc9

No merge-blocking issue was established; merge after normal checks.

Pre-merge checks · Passed 5
Passed Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: matching controls disabled by an ancestor fieldset.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each fieldset gate
The first legend marks a different state
Selects pass the setting down
To options gathered all around
Tests trace the paths, both wide and small
Then hops away beyond them all

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

Comment thread src/pseudo-selectors/aliases.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium impact] Updates CSS selector logic for disabled form controls.

Fix the incorrect option and optgroup state before merging.

Findings

  1. P1 Options get the wrong state ▶

Summary

The PR adds disabled-fieldset inheritance and preserves the first direct legend's exemption.

  • Controls inside disabled fieldsets now match :disabled.

Reviews (2) · Last reviewed commit: "fix(pseudos): preserve disabled ancestor..." · Reviewed by Greptile

Comment thread src/pseudo-selectors/aliases.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8e728e785

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/pseudo-selectors/aliases.ts Outdated
fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
:is(button, input, select, textarea, fieldset):is(
fieldset[disabled] > :not(legend:first-of-type),
fieldset[disabled] > :not(legend:first-of-type) *

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor disabled ancestors above the query context

When the search root is below the fieldset—for example <fieldset disabled><div id="root"><input></div></fieldset> followed by selectAll(":disabled", root)—this nested combinator is compiled with root as its context. With the default relativeSelector handling, fieldset[disabled] must then be root or its descendant, so the actual ancestor cannot satisfy this branch; the input is omitted from :disabled and subsequently matches :enabled. Disabled state should not change with the chosen search subtree, so this ancestor check needs to run without that context restriction.

Useful? React with 👍 / 👎.

optgroup[disabled] > option,
fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
:is(button, input, select, textarea, fieldset)${disabledByFieldset},
:is(optgroup, option):is(select[disabled] *, select${disabledByFieldset} *)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Options get the wrong state

For <select disabled><option>X</option></select>, this branch makes the option match :disabled instead of :enabled. Options do not inherit a select's disabled state. An option is disabled by its own attribute or a disabled parent optgroup; an optgroup needs its own attribute.

The same mistake occurs when a fieldset disables the select, so callers get the wrong query results in both cases. Remove this branch and update the tests that expect inherited state.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95cc9e3b17

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

optgroup[disabled] > option,
fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
:is(button, input, select, textarea, fieldset)${disabledByFieldset},
:is(optgroup, option):is(select[disabled] *, select${disabledByFieldset} *)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Stop treating disabled select descendants as disabled

For <select disabled>...</select>, HTML only makes the select itself disabled: an optgroup needs its own disabled attribute, while an option needs its own attribute or a disabled parent optgroup. This branch newly makes both descendants match :disabled (and disappear from :enabled) for every disabled select, including selects disabled by a fieldset, reversing the prior and browser behavior; retain fieldset inheritance on the select without propagating it to these descendants.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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