-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataForm: panel layout can open as dropdown or modal
#71212
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
Conversation
packages/dataviews/src/components/dataform/stories/index.story.tsx
Outdated
Show resolved
Hide resolved
|
Size Change: +674 B (+0.04%) Total Size: 1.92 MB
ℹ️ View Unchanged
|
This is inconsistent with almost every other Modal instance. I’m not quite following the reasoning for disabling this behavior. When a modal has a dedicated close button (as is the case here) I think it’s reasonable to expect that clicking outside the modal will close it. |
|
@jameskoster Does clicking outside of a modal "apply" or "cancel" changes? Apply would be safest to avoid discarding wanted changes. But its not explicit. |
|
I’d vote for consistency with other modals where clicking outside is the same as clicking close or cancel. |
b195587 to
e3e552e
Compare
|
@jameskoster I've added size |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 914de3d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17069927920
|
packages/dataviews/src/types.ts
Outdated
| export type PanelLayout = { | ||
| type: 'panel'; | ||
| labelPosition?: LabelPosition; | ||
| panelType?: 'dropdown' | 'modal'; |
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.
For naming, what do you think of renaming this prop along the lines of openAs instead? So many "type" things that the meaning dilutes, and it all becomes confusing.
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 in 16658a8
packages/dataviews/src/types.ts
Outdated
|
|
||
| export type CombinedFormField = { | ||
| id: string; | ||
| content?: string | ReactElement; |
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 feel this prop is disconnected from the fields-based behavior we have everywhere, and it's also disconnected from the existing logic in the panel that takes the 1st child (fieldDefinition). That fieldDefinition is used to render the field label + control displaying (via readOnly prop) + display content (Edit or render). That all needs to be accounted for. We could explore this separate from this PR, as the modal behavior is working fine.
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 in 914de3d Will raise separately.
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 seems what we need is the ability to find a "summary field" for the panel layout.
A potential idea to explore: try to find a field that matches the combined field's id (I think now we just discard it) — any other layout will still use the children. Only if that fails, fallback to use the 1st field that doesn't have children (current behavior).
Alternatively, we could introduce some more config that declares what the summary is. For example, add a summary prop to the panel layout that lists the fields to be used as summary (all of them will be used). Or perhaps there's a render prop that works as a React component and receives the same props as field.render.
dropdown or modal
…1212) Co-authored-by: mikejolley <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: oandregal <[email protected]>
What?
This PR adds a
modalpanel type. Enabled by settingpanelTypefromdropdowntomodal.On edit, controls are presented in a modal. There is local state to prevent onChange firing right away. onChange is triggered when you click the
applybutton. If you cancel or clickxchanges are discarded. Clicking outside of the modaldoes nothing as we want to user to use one of the CTAcancels any changes.On top of this, I wanted to include a way to control the data presented for combined fields so you can present a set of data in a unique way. I've included this example in Storybook:Moving to separate PR.Moving to separate PR.
Why?
How?
contentpropTesting Instructions
?path=/story/dataviews-dataform--combined-fields&args=panelType:modal;labelPosition:top