-
-
Notifications
You must be signed in to change notification settings - Fork 280
fix: getFieldsValue can not get fully store #774
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
Changes from 5 commits
1eb9f89
4e063b7
2d791fb
620a6b9
438396c
9d6a81d
a45d44a
425d119
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| export interface ScreenProps { | ||
| visible?: boolean; | ||
| children?: React.ReactNode; | ||
| className?: string; | ||
| style?: React.CSSProperties; | ||
| } | ||
|
|
||
| const Screen: React.FC<ScreenProps> = ({ visible = false, children, className, style }) => { | ||
| // Simple fade in/out animation using inline styles | ||
| const screenStyle: React.CSSProperties = { | ||
| transition: 'opacity 0.3s, transform 0.3s', | ||
| opacity: visible ? 1 : 0, | ||
| transform: visible ? 'scale(1)' : 'scale(0.8)', | ||
| display: visible ? 'block' : 'none', | ||
| ...style, | ||
| }; | ||
|
|
||
| // Combine className if provided | ||
| const combinedClassName = className ? `rc-field-form-screen ${className}` : 'rc-field-form-screen'; | ||
|
|
||
| return ( | ||
| <div | ||
| className={combinedClassName} | ||
| style={screenStyle} | ||
| > | ||
| {children} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Screen; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1171,4 +1171,23 @@ describe('Form.List', () => { | |||||
| list: [{ name: 'A' }, { name: 'BB' }, { name: 'C' }, { name: 'D' }], | ||||||
| }); | ||||||
| }); | ||||||
|
|
||||||
| it('getFieldsValue(["list"]) should same as getFieldsValue().list', async () => { | ||||||
| generateForm( | ||||||
| fields => | ||||||
| fields.map(field => ( | ||||||
| <Field {...fields} name={[field.name, 'name']} key={field.key}> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There appears to be a typo in this line. You are spreading
Suggested change
|
||||||
| <Input /> | ||||||
| </Field> | ||||||
| )), | ||||||
| { | ||||||
| initialValues: { | ||||||
| list: [{ name: 'bamboo', notExist: 'little' }], | ||||||
| }, | ||||||
| }, | ||||||
| ); | ||||||
|
|
||||||
| expect(form.current!.getFieldsValue()).toEqual({ list: [{ name: 'bamboo' }] }); | ||||||
| expect(form.current!.getFieldsValue(['list'])).toEqual({ list: [{ name: 'bamboo' }] }); | ||||||
| }); | ||||||
| }); | ||||||
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.
The fade-in animation may not work as expected due to the use of
display: 'none'. Whenvisiblebecomestrue, thedisplayproperty changes fromnonetoblockandopacitychanges to1within the same render cycle. The browser doesn't have a 'from' state to transition from, so the element will appear instantly rather than fading in. The fade-out animation will work correctly.To achieve a proper fade-in animation while still using
display: 'none'(presumably to unmount fields), you would typically need a more complex implementation involvinguseEffectand timeouts to manage rendering and style changes in separate phases, or use a library likereact-transition-group. If an instant appearance on 'show' is acceptable, then this implementation is fine.