Skip to content

Commit 6da4ec4

Browse files
authored
Merge branch 'main' into main
2 parents 0a0b0de + 5edbd85 commit 6da4ec4

File tree

12 files changed

+175
-163
lines changed

12 files changed

+175
-163
lines changed

.changeset/wise-games-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"formik": patch
3+
---
4+
5+
Mark `formik` as side-effect free in `package.json`

.github/workflows/benchmark.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
detectChangedSourceFiles:
10+
name: 'determine changes'
11+
runs-on: ubuntu-latest
12+
outputs:
13+
changes: ${{ steps.changed-files-yaml.outputs.src_any_changed }}
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Detect changed files
17+
id: changed-files-yaml
18+
uses: tj-actions/changed-files@v39
19+
with:
20+
files_yaml: |
21+
src:
22+
- packages/formik/src/**
23+
- packages/formik/package.json
24+
- packages/formik-native/src/**
25+
- packages/formik-native/package.json
26+
benchmark:
27+
if: needs.detectChangedSourceFiles.outputs.changes == 'true'
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
steps:
32+
- uses: actions/checkout@v3
33+
34+
- uses: actions/setup-node@v3
35+
with:
36+
cache: yarn
37+
node-version-file: .nvmrc
38+
39+
- name: Detect changed files
40+
id: changed-files-yaml
41+
uses: tj-actions/changed-files@v39
42+
with:
43+
files_yaml: |
44+
src:
45+
- packages/formik/src/**
46+
- packages/formik-native/src/**
47+
48+
- name: Install & build
49+
run: |
50+
node --version
51+
npm --version
52+
yarn --version
53+
yarn install --frozen-lockfile
54+
yarn build:benchmark
55+
56+
- name: Download previous benchmark data
57+
uses: actions/cache@v3
58+
with:
59+
path: ./benchmark-cache
60+
key: ${{ runner.os }}-benchmark
61+
62+
- name: Run benchmark
63+
run: yarn benchmark
64+
65+
- name: Store benchmark result
66+
uses: benchmark-action/github-action-benchmark@v1
67+
with:
68+
tool: benchmarkjs
69+
external-data-json-path: ./benchmark-cache/benchmark-data.json
70+
output-file-path: output.txt
71+
# comment for PRs that's updated with current perf relative to baseline (main)
72+
summary-always: true
73+
# warn if slowness is detected; might be transient on rerun
74+
alert-threshold: 110%
75+
comment-on-alert: true
76+
fail-on-alert: true
77+
# if things get considerably slower, deny the PR
78+
fail-threshold: 120%
79+
# needed for commenting on PRs
80+
github-token: ${{ secrets.GITHUB_TOKEN }}
81+
interaction:
82+
if: needs.detectChangedSourceFiles.outputs.changes == 'true'
83+
timeout-minutes: 10
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v3
87+
- uses: actions/setup-node@v3
88+
with:
89+
cache: yarn
90+
node-version-file: .nvmrc
91+
92+
- name: Install dependencies
93+
run: yarn install --frozen-lockfile
94+
95+
- name: Get installed Playwright version
96+
id: playwright-version
97+
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').dependencies['@playwright/test'].version)")" >> $GITHUB_ENV
98+
99+
- name: Cache playwright binaries
100+
uses: actions/cache@v3
101+
id: playwright-cache
102+
with:
103+
path: |
104+
~/.cache/ms-playwright
105+
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
106+
107+
- name: Install Playwright Browsers
108+
run: yarn playwright install --with-deps
109+
if: steps.playwright-cache.outputs.cache-hit != 'true'
110+
- run: yarn playwright install-deps
111+
if: steps.playwright-cache.outputs.cache-hit != 'true'
112+
113+
- name: Run Playwright tests
114+
run: yarn playwright test
115+
- uses: actions/upload-artifact@v3
116+
if: always()
117+
with:
118+
name: playwright-report
119+
path: playwright-report/
120+
retention-days: 5
121+
size:
122+
if: needs.detectChangedSourceFiles.outputs.changes == 'true'
123+
runs-on: ubuntu-latest
124+
steps:
125+
- uses: actions/checkout@v3
126+
with:
127+
fetch-depth: 1
128+
- uses: preactjs/compressed-size-action@v2
129+
with:
130+
repo-token: '${{ secrets.GITHUB_TOKEN }}'
131+
build-script: 'turbo run build --filter {./packages/*}...'
132+
unit:
133+
if: needs.detectChangedSourceFiles.outputs.changes == 'true'
134+
runs-on: ubuntu-latest
135+
strategy:
136+
fail-fast: false
137+
steps:
138+
- uses: actions/checkout@v3
139+
- uses: actions/setup-node@v3
140+
with:
141+
cache: yarn
142+
node-version-file: .nvmrc
143+
- name: Install deps, build, and test
144+
run: |
145+
node --version
146+
npm --version
147+
yarn --version
148+
yarn install --frozen-lockfile
149+
yarn test --coverage
150+
env:
151+
CI: true
152+
NODE_OPTIONS: --max-old-space-size=4096

.github/workflows/playwright.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/setup-node@v3
1717
with:
1818
cache: yarn
19-
node-version: 18
19+
node-version-file: .nvmrc
2020

2121
- name: Install Dependencies
2222
run: yarn install

.github/workflows/size.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18

docs/api/formik.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Set `touched` imperatively. Calling this will trigger validation to run if `vali
216216

217217
If `validateOnBlur` is set to `true` and there are errors, they will be resolved in the returned `Promise`.
218218

219-
#### `setValues: (fields: React.SetStateAction<{ [field: string]: any }>, shouldValidate?: boolean) => void`
219+
#### `setValues: (fields: React.SetStateAction<{ [field: string]: any }>, shouldValidate?: boolean) => Promise<void | FormikErrors<Values>>`
220220

221221
Set `values` imperatively. Calling this will trigger validation to run if `validateOnChange` is set to `true` (which it is by default). You can also explicitly prevent/skip validation by passing a second argument as `false`.
222222

docs/guides/form-submission.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ To submit a form in Formik, you need to somehow fire off the provided `handleSub
2323

2424
### Submission
2525

26-
- Proceed with running your submission handler (i.e.`onSubmit` or `handleSubmit`)
27-
- _you call `setSubmitting(false)`_ in your handler to finish the cycle
26+
- Proceed with running the submission handler (i.e. `onSubmit` or `handleSubmit`)
27+
- Did the submit handler return a promise?
28+
- Yes: Wait until it is resolved or rejected, then set `setSubmitting` to `false`
29+
- No: _Call `setSubmitting(false)`_ to finish the cycle
2830

2931
## Frequently Asked Questions
3032

@@ -55,3 +57,12 @@ Disable whatever is triggering submission if `isSubmitting` is `true`.
5557
If `isValidating` is `true` and `isSubmitting` is `true`.
5658

5759
</details>
60+
61+
<details>
62+
<summary>Why does `isSubmitting` remain true after submission?</summary>
63+
64+
If the submission handler returns a promise, make sure it is correctly resolved or rejected when called.
65+
66+
If the submission handler does not return a promise, make sure `setSubmitting(false)` is called at the end of the handler.
67+
68+
</details>

0 commit comments

Comments
 (0)