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

feat(Forms): auto-open iterate container items when validation errors and make Iterate.Toolbar fully customizable #3877

Merged
merged 23 commits into from
Sep 12, 2024

Conversation

tujoworker
Copy link
Member

@tujoworker tujoworker commented Aug 28, 2024

Quick example of a fully customized Toolbar:

<Form.Handler>
  <Iterate.Array path="/countries" defaultValue={[null]}>
    <Iterate.ViewContainer
      toolbar={
        <Iterate.Toolbar>
          {({ items }) => {
            if (items.length === 1) {
              return <Iterate.ViewContainer.EditButton />
            }
            return (
              <>
                <Iterate.ViewContainer.EditButton />
                <Iterate.ViewContainer.RemoveButton />
              </>
            )
          }}
        </Iterate.Toolbar>
      }
    >
      <Value.SelectCountry
        label="Land du er statsborger i"
        itemPath="/"
      />
    </Iterate.ViewContainer>

    <Iterate.EditContainer
      toolbar={
        <Iterate.Toolbar>
          {({ items }) => {
            if (items.length === 1) {
              return null
            }

            return (
              <>
                <Iterate.EditContainer.DoneButton />
                <Iterate.EditContainer.CancelButton />
              </>
            )
          }}
        </Iterate.Toolbar>
      }
    >
      <Field.SelectCountry
        label="Land du er statsborger i"
        itemPath="/"
        required
      />
    </Iterate.EditContainer>
  </Iterate.Array>

  <Iterate.PushButton
    path="/countries"
    pushValue={null}
    text="Legg til flere statsborgerskap"
  />
</Form.Handler>

Copy link

vercel bot commented Aug 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eufemia ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 8:21am

Copy link

codesandbox-ci bot commented Aug 28, 2024

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.

langz

This comment was marked as outdated.

@tujoworker tujoworker force-pushed the feat/iterate-container-mode branch from 03baf8d to 4e6f93a Compare August 28, 2024 20:17
@tujoworker tujoworker force-pushed the feat/iterate-container-mode branch from 4edc95b to 3031032 Compare August 30, 2024 10:58
@tujoworker tujoworker force-pushed the feat/iterate-container-mode branch from 3031032 to 0c6e41c Compare August 30, 2024 11:57
@tujoworker tujoworker force-pushed the feat/iterate-container-mode branch 2 times, most recently from 724a3c7 to f8accba Compare August 30, 2024 16:25
@tujoworker tujoworker force-pushed the feat/iterate-container-mode branch from f8accba to 8f8c5e0 Compare August 30, 2024 18:40
@tujoworker tujoworker force-pushed the feat/iterate-container-mode branch from 8f8c5e0 to 1e0bc7e Compare August 30, 2024 18:52
@tujoworker tujoworker force-pushed the feat/iterate-container-mode branch from daa7c1f to ccd44b5 Compare August 31, 2024 06:56
@tujoworker tujoworker force-pushed the feat/iterate-container-mode branch from ccd44b5 to 3677715 Compare August 31, 2024 08:02
@tujoworker

This comment was marked as outdated.

@tujoworker
Copy link
Member Author

Can you test the keyboard usage again? Have made some improvements there.

@langz

This comment was marked as resolved.

@langz
Copy link
Contributor

langz commented Sep 11, 2024

https://eufemia-git-feat-iterate-container-mode-eufemia.vercel.app/uilib/extensions/forms/Iterate/Array/demos/#initially-open
Sometimes when I get the error message "Feilene ovenfor må rettes" it looks like it misses margin/spacing. But only in certain situations? In the following video, you can see it happen:

Screen.Recording.2024-09-11.at.23.06.03.mov

Looking like this(see the last error message):
Screenshot 2024-09-12 at 09 32 01

I believe this is newly introduced, as I did not experience this last week.

@langz

This comment was marked as resolved.

@tujoworker

This comment was marked as resolved.

@tujoworker

This comment was marked as resolved.

@langz

This comment was marked as resolved.

tujoworker and others added 2 commits September 12, 2024 10:06
…r/__tests__/PushContainer.test.tsx

Co-authored-by: Anders <[email protected]>
…r/__tests__/PushContainer.test.tsx

Co-authored-by: Anders <[email protected]>
@langz
Copy link
Contributor

langz commented Sep 12, 2024

https://eufemia-git-feat-iterate-container-mode-eufemia.vercel.app/uilib/extensions/forms/Iterate/Array/demos/#initially-open Sometimes when I get the error message "Feilene ovenfor må rettes" it looks like it misses margin/spacing. But only in certain situations? In the following video, you can see it happen:

Screen.Recording.2024-09-11.at.23.06.03.mov
Looking like this(see the last error message): Screenshot 2024-09-12 at 09 32 01

I believe this is newly introduced, as I did not experience this last week.

I'm still able to reproduce this now.

@tujoworker tujoworker merged commit 52326bf into main Sep 12, 2024
10 checks passed
@tujoworker tujoworker deleted the feat/iterate-container-mode branch September 12, 2024 08:59
tujoworker added a commit that referenced this pull request Sep 12, 2024
… for hiding buttons when there is only one item in the array (#3919)

Based on #3877


Quick example using the new Toolbar variant:

```tsx
<Form.Handler>
  <Iterate.Array path="/countries" defaultValue={[null]}>
    <Iterate.ViewContainer toolbarVariant="minimumOneItem"
    >
      <Value.SelectCountry
        label="Land du er statsborger i"
        itemPath="/"
      />
    </Iterate.ViewContainer>

    <Iterate.EditContainer toolbarVariant="minimumOneItem"
    >
      <Field.SelectCountry
        label="Land du er statsborger i"
        itemPath="/"
        required
      />
    </Iterate.EditContainer>
  </Iterate.Array>

  <Iterate.PushButton
    path="/countries"
    pushValue={null}
    text="Legg til flere statsborgerskap"
  />
</Form.Handler>
```

---------

Co-authored-by: Anders <[email protected]>
tujoworker pushed a commit that referenced this pull request Sep 12, 2024
## [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))
@tujoworker
Copy link
Member Author

🎉 This PR is included in version 10.48.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants