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

Legg til ref forwarding i Select #1689

Merged
merged 3 commits into from Jan 5, 2021
Merged

Legg til ref forwarding i Select #1689

merged 3 commits into from Jan 5, 2021

Conversation

piofinn
Copy link
Contributor

@piofinn piofinn commented Dec 9, 2020

📥 Proposed changes

Siden flere team nå bruker react-hook-form er det ønskelig å kunne bruke ref for å registrere skjemafelter. Selv om man kan bruke custom komponenter ved hjelp av Controller mister man noe funksjonalitet, som for eksempel å kunne fokusere på feltet ved feil i skjemaet.

Denne PRen legger til støtte for dette i Select, ved å legge til et skjult <select>-element som speiler valgt verdi, og som dytter fokus videre til vårt custom element. Det blir dermed mulig å bruke feltet med ref={register()} i react-hook-form.

  • PRen legger også til støtte for name-attributten i både Select og NativeSelect
  • Regner dette som en BREAKING CHANGE pga. forwardRef

☑️ Submission checklist

  • I have read the CONTRIBUTING doc
  • yarn build works locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

💬 Further comments

Jeg har ikke klart å finne noen bakdeler ved denne tilnærmingen med tanke på ting som UU eller generell brukeropplevelse; implementasjonen virker helt transparent. Men jeg tipper det finnes edge-cases som jeg ikke har tenkt på. Setter pris på om noen legger hodet i bløt på denne 😊

Skal få laget en liten sandbox med react-hook-form ila dagen så det blir enklere å teste endringene.

@piofinn piofinn self-assigned this Dec 9, 2020
@piofinn piofinn added the ✨ enhancement Forslag til nye funksjoner og endringer label Dec 9, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 9, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 517c66c:

Sandbox Source
all-components Configuration

affects: @fremtind/jkl-select-react

Adds ref forwarding to the Select component using a hidden native select element reflecting the
value of the field

BREAKING CHANGE:
Added forwardRef, which may break behaviour
@piofinn piofinn merged commit db76511 into master Jan 5, 2021
@piofinn piofinn deleted the feat/select-ref branch January 5, 2021 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement Forslag til nye funksjoner og endringer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants