-
Notifications
You must be signed in to change notification settings - Fork 399
[Dynamic Form] Fix for 1788/1794 and add styles property for support customizing styling #1913
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
[Dynamic Form] Fix for 1788/1794 and add styles property for support customizing styling #1913
Conversation
Hi @joelfmrodrigues , could you look into it if you have some time? |
Hi @joaojmendes any updates here? |
Hi all, just wanted to add my feedback: this would be a very useful feature so looking forward to it 👍 |
@wuxiaojun514 apologies for the delay, I have seen the email notification when you tagged me a while ago but things have been a bit chaotic (in a good way 😇 ) at my end and I have been unable to look into it |
Hi @joelfmrodrigues , never mind, just take your time 😄 |
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.
Hey @wuxiaojun514, this is a great improvment, thanks!
I made some suggestions and one issue when trying to test on my side, please have a look and let me know.
subComponentStyles:{ | ||
fieldStyles:{ | ||
errormessage:{ | ||
"font-size":"18px" //overwrite the error message font size in Dynamic Field |
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.
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.
It doesn't work on my side as well. Currently subComponentStyles
is not working. I will fix it and let you know
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.
@michaelmaillot I have fixed it now.
I also updated the sample in documentation https://github.com/wuxiaojun514/sp-dev-fx-controls-react/blob/fix-for-1788-and-add-styles-property/docs/documentation/docs/controls/DynamicForm.md#how-to-use-styles-property
to handle normal text field (the error message in normal text field is generated inside the fluent ui TextField control, so we need use selectors
to overwrite it.
styles={{
sectionFormField: {
selectors: {
':has(div)': {
[`@media (min-width: 1280px)`]: {
"min-width": '21%',
"max-width": '21%' //force show 4 columns per row in big screen size when enabled list custom formatting
}
},
},
},
subComponentStyles: {
fieldStyles: {
errormessage: {
"font-size": "18px" //overwrite the error message font size in Dynamic Field for Lookup/Note/Date fields (The error message element is generated directly in Dynamic Field control)
},
fieldDisplay: {
selectors: {
'.ms-TextField-errorMessage': {
"font-size": "18px !important" //overwrite the error message font size in Dynamic Field for TextField (error message element is wrapped in Fluent UI TextField control, we cannot modify it directly,we have to use 'selectors' to change it)
}
}
}
}
}
}}
fixed the subcomponent styles doesn't work in dynamic field issue
Hi @michaelmaillot |
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.
I tried again and I confirm it works now!
Just a few updates and we'll be good!
In this example it shows 4 columns (by default it shows 3 columns per row) in one row if screen size is bigger than 1280px (it requires enable list formatting first) | ||
and make the error message font size a bit large. | ||
```TypeScript | ||
styles={{ |
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.
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.
done, I removed all indent on this sample code.
fieldLabel:IStyle; | ||
labelContainer:IStyle; | ||
pickersContainer:IStyle; | ||
FieldEditor:IStyle; |
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.
Shouldn't it be written like this?
FieldEditor:IStyle; | |
fieldEditor:IStyle; |
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.
I have corrected the class name and related document (Actually I copied this name from old DynamicForm.module.scss
file...)
Hey @wuxiaojun514, Thanks for the updates, just this last one remaining update and we'll be good for the merge: https://github.com/pnp/sp-dev-fx-controls-react/pull/1913/files#r1993102589 |
Merged manually. Thank you! |
What's in this Pull Request?
This PR is mainly for
Dynamic Form has quite a lot of problems when custom list formatting is enabled. I fixed the issues ([Dynamic Form] Cannot read properties of undefined (reading 'sections') #1788 ,[Dynamic Form] Implement @class extensibility for DynamicForm and DynamicField, add onPreRender delegate. #1794 Bad UI) .

The author of [Dynamic Form] Implement @class extensibility for DynamicForm and DynamicField, add onPreRender delegate. #1794 provided some other approach to customize the styling but I feel this PR should work.
Now it will show 3 columns per row if it has custom form layout
Added two properties (styles and className) to support customization on styling and converted this component as style-able component. Deleted the /dynamicForm/DynamicForm.module.scss file and put its content into /dynamicForm/DynamicForm.sytles.ts and /dynamicForm/dynamicField/DynamicField.styles.ts . I kept the same classname on styling to make this change smoothly.
I have documented the new feature on DynamicForm.md and given an example how to overwrite styling
I know it is quite a big change, please let me know if anything missing.
Guidance