Skip to content
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

Make input fields easier to focus even without FormControl wrapping #97

Merged
merged 1 commit into from
Feb 21, 2022

Conversation

selbekk
Copy link
Contributor

@selbekk selbekk commented Feb 21, 2022

This fixes a bug where - if you didn't wrap your <Input /> component in a <FormControl /> component, and didn't provide your own ID - you couldn't click the overlaying label to focus the input.

@changeset-bot
Copy link

changeset-bot bot commented Feb 21, 2022

🦋 Changeset detected

Latest commit: aaf0b69

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@vygruppen/spor-input-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

{...props}
ref={ref}
placeholder=" " // This is needed to make the label work as expected
/>
<FormLabel>{label}</FormLabel>
<FormLabel htmlFor={id} pointerEvents="none">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Man kan argumentere for at pointerEvents="none" på en label er feil, men i dette tilfelle vil resultatet bli det samme om man klikker på labelen eller ikke. Hele labelen vil alltid være på innsiden av input-feltet, så da ser jeg ikke noe problem med å gjøre det slik.

Alternativt så kunne man brukt de interne hookene useFormControlProps og useFormControl for å hente ut riktige IDer for å binde dem sammen, men det har sin egen risikoprofil (de er ikke dekket av semver f.eks). Så summa summarum, et reflektert trade-off.

@selbekk selbekk merged commit 011ae8d into main Feb 21, 2022
@selbekk selbekk deleted the fix-input-clickability branch September 7, 2023 20:04
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.

None yet

1 participant