-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(Forms): auto-open Form.Section container when fields have errors and add validateInitially
prop
#3878
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was quick 😄
Looks good 👍
d543368
to
f2ddece
Compare
Here is a quick demo/example (have not tested it yet): https://eufemia-git-feat-section-error-mode-eufemia.vercel.app/uilib/extensions/forms/Form/Section/demos/#show-errors-on-the-whole-section |
f2ddece
to
6faf68b
Compare
The edit container opens fine 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :)
Is it a potential error that when pressing the code button under the example, the screen sort of flashes?
Or is it just because of some scroll and/or animation stuff?
Screen.Recording.2024-08-28.at.20.59.21.mov
Further, just a nitpick, but it's a bit unfortunate that it autoscrolls to the new example when visiting the docs https://eufemia-git-feat-section-error-mode-eufemia.vercel.app/uilib/extensions/forms/Form/Section/
Makes it so that we can't link to other headings in the same docs, like https://eufemia-git-feat-section-error-mode-eufemia.vercel.app/uilib/extensions/forms/Form/Section/#overwrite-props, as it will autoscroll to our new example.
Could that also be a problem in an application, or something they would/could opt-out of?
Let's say if you enter a page, and on the bottom of the page they have this form with validateFieldsInitially, would it automatically scroll the user down to the bottom of the page?
packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Form/Section/demos.mdx
Outdated
Show resolved
Hide resolved
Just to be curious, this of course requires that all fields used in the form.section supports/has the If so, is it so that this |
@andlbrei Nice finding – the latest commit should fix it. But I have not tested it. Can you check it out? |
@langz Actually no. And if a dev makes their own Field, they should use the |
Very true, we should not set focus when it opens initially. Will have to fix it + test. |
@tujoworker works fine now 👍 |
@andlbrei How about renaming the prop from
|
@tujoworker I have no objections to that 👍 |
validateFieldsInitially
to Form.SectioncontainerMode="openWhenFieldValidationError"
to Form.Section
08cbcac
to
6180465
Compare
Then I think we go for |
6180465
to
4070ad0
Compare
@tujoworker Looks very good now 👍 I like the default to auto, that might make a lot of sense. |
@andlbrei, thanks so much for testing and giving feedback, I see that both you and I did not test the latest commit of @tujoworker as it wasn't pushed until recently. |
@langz I did it while you wrote your message I think 😅 |
I think this "issue" is back again, when testing in the deploy preview now, it autoscrolls to a different example/header than what I'm linking to(linking to usage header, but scrolls to something else): https://eufemia-git-feat-section-error-mode-eufemia.vercel.app/uilib/extensions/forms/Form/Section/#usage Screen.Recording.2024-09-11.at.12.15.30.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good now, I love the API improvements, great work ❤️
Just one thought/question, what will happen if setting validateInitially={true} on Form.Section which has a single field with validateInitially={false}, which property dictates if the field will be validated initially? Perhaps we should add a test for the answer of this question?
7f23bca
to
7517098
Compare
Done. |
b432a50
to
26ae497
Compare
Ohh noo. But added a better test and fix ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
…rms/Form/Section/demos.mdx Co-authored-by: Anders <[email protected]>
…lidationError" to "auto"
…Initially on section
36e10ed
to
1dd23c9
Compare
## [10.48.0](v10.47.0...v10.48.0) (2024-09-12) ### 🐛 Bug Fixes * **countries:** Fixes wrong country code for Martinique [#3915](#3915) ([a9f86e4](a9f86e4)) * **countries:** Remove outdated countries [#3915](#3915) ([36ef5cf](36ef5cf)) * **Forms:** rename 'Macedonia' to 'North Macedonia' ([#3918](#3918)) ([a4eb8a4](a4eb8a4)) * **Forms:** rename "Hviterussland" to "Belarus" ([#3917](#3917)) ([702118a](702118a)) * removes outdated countries based on ISO 3166-1 alpha-2 ([#3916](#3916)) ([a045acd](a045acd)) ### ✨ Features * **Forms:** add `toolbarVariant="minimumOneItem"` to Iterate.Toolbar for hiding buttons when there is only one item in the array ([#3919](#3919)) ([3367a77](3367a77)), closes [#3877](#3877) * **Forms:** add `validator` support to Iterate.Array ([#3926](#3926)) ([6fd439e](6fd439e)) * **Forms:** auto-open Form.Section container when fields have errors and add `validateInitially` prop ([#3878](#3878)) ([9b49006](9b49006)) * **Forms:** auto-open iterate containers when validation errors and make `Iterate.Toolbar` fully customizable ([#3877](#3877)) ([52326bf](52326bf)), closes [#3919](#3919) * **Forms:** show optional label when a field uses `required={false}` and add `labelSuffix` prop to each field ([#3921](#3921)) ([60e440a](60e440a)) * **Wizard:** add `preventNavigation` callback function to `onStepChange` ([#3924](#3924)) ([5ec2772](5ec2772))
🎉 This PR is included in version 10.48.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This feature allows a dev to put on a Form.Section. When a field inside has an error/ or is validating negatively, the section will automatically switch to edit mode and show these errors, without pressing submit on the form.
Demo.
Quick example: