-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use native fieldset
instead of div
by default for <Fieldset />
component
#3237
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is necessary if we want to make use of the default fieldset tag (which also disables native form elements)
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
RobinMalfait
changed the title
Use native
Use native May 24, 2024
fieldset
by default for <Fieldset />
componentfieldset
instead of div
by default for <Fieldset />
component
This allows us to compute the `tag` name of a component. We can use a shortcut based on the `props.as` and/or the `DEFAULT_XXX_TAG` of a component. If this is not known/passed, then we compute it based on the `ref` instead which requires an actual re-render.
RobinMalfait
force-pushed
the
feat/use-fieldset-tag
branch
from
May 24, 2024 14:53
a296006
to
f64ddeb
Compare
This was referenced Jul 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the default behavior of our
<Fieldset />
component.Initially we used a
div
becausefieldset
/legend
is hard to style otherwise. However, a fieldset on its own is still useful and has some benefits (such as disabling all native form elements if thefieldset
itself is disabled).We still setup an internal
DisabledProvider
such that our own components can read from this state and disable themselves accordingly.This is technically a breaking change, but I doubt that anyone runs into this issue.
If so, you can apply the following diff to fix it:
Note: if you were already using
disabled
on the<Fieldset disabled>
, and you useas="div"
then you won't have the default behavior where it disables these form elements.Implementation looks a bit more complex, but essentially added new functionality to compute what the final
tagName
is of a component and based on this information we know which props to render. If a nativefieldset
is used, we can use thedisabled
prop, if another element is used we can renderaria-disabled
and arole="group"
.The new internal
useResolveTag
will compute the tag name, and it defaults to theprops.as
value.