Skip to content

Commit

Permalink
chore: fix form demo error (ant-design#44549)
Browse files Browse the repository at this point in the history
* fix: fix form demo error

* update snap
  • Loading branch information
li-jia-nan committed Aug 31, 2023
1 parent ae53a45 commit a608bfa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions components/form/__tests__/__snapshots__/demo.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4563,6 +4563,7 @@ exports[`renders components/form/demo/inline-login.tsx correctly 1`] = `
>
<button
class="ant-btn ant-btn-primary"
disabled=""
type="submit"
>
<span>
Expand Down
5 changes: 3 additions & 2 deletions components/form/demo/inline-login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Button, Form, Input } from 'antd';

const App: React.FC = () => {
const [form] = Form.useForm();
const [, forceUpdate] = useState({});
const [clientReady, setClientReady] = useState<boolean>(false);

// To disable submit button at the beginning.
useEffect(() => {
forceUpdate({});
setClientReady(true);
}, []);

const onFinish = (values: any) => {
Expand Down Expand Up @@ -39,6 +39,7 @@ const App: React.FC = () => {
type="primary"
htmlType="submit"
disabled={
!clientReady ||
!form.isFieldsTouched(true) ||
!!form.getFieldsError().filter(({ errors }) => errors.length).length
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"@antv/g6": "^4.8.13",
"@argos-ci/core": "^0.9.0",
"@babel/eslint-plugin": "^7.19.1",
"@biomejs/biome": "^1.0.0",
"@codesandbox/sandpack-react": "^2.6.9",
"@dnd-kit/core": "^6.0.7",
"@dnd-kit/modifiers": "^6.0.1",
Expand Down Expand Up @@ -291,7 +292,6 @@
"remark-cli": "^11.0.0",
"remark-lint": "^9.0.0",
"remark-preset-lint-recommended": "^6.0.0",
"@biomejs/biome": "^1.0.0",
"semver": "^7.3.5",
"simple-git": "^3.0.0",
"size-limit": "^8.1.0",
Expand Down

0 comments on commit a608bfa

Please sign in to comment.