-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Add checkValidation and isValid methods to window.podsDFV #7064
base: main
Are you sure you want to change the base?
Conversation
PR Summary
|
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.
Looks great so far
This PR is completed for #6898 Note: Does not prevent save when fields are invalid. |
4f6718b
to
0e4e052
Compare
5b051b7
to
7d59e27
Compare
New TODO list:
|
@sc0ttkclark I am looking at how to show validation messages when saving and also how to block saving. Here are some notes for me and/ or you.
|
Something like this in //Track when post is being saved so we can trigger validation
const [isPostSaving,setIsPostSaving] = useState(false);
//subscribe to "core/core-editor" to track when post is being saved
useEffect( () => {
const editor = select( 'core/editor' );
const unsubscribe = subscribe( () => {
setIsPostSaving(editor.isSavingPost());
} );
//Clean up when component unmounts
return unsubscribe;
}, [select,subscribe,setIsPostSaving] ); I tried to do this in const editor = storeSelect( 'core/editor' );
const isEditorSaving = editor.isSavingPost();
const isEditorSavingLocked = editor.isSavingLocked(); |
@Shelob9 Here's what I ended up having to do to workaround the bug with locking post saving (both when post has not yet been published and on subsequent saves which have slightly different timing): |
Description
Add checkValidation and isValid methods to window.podsDFV
What we need:
pods/ui/js/dfv/src/hooks/useValidation.js
Lines 4 to 5 in 6f79abd
needsRevalidate
bool in store. Make it a dependency of this effect.pods/ui/js/dfv/src/hooks/useValidation.js
Lines 7 to 25 in 6f79abd
Related GitHub issue(s)
Fixes #6898
Testing
widow.PodsDFV.formIsValid()
in console, expect falsewindow.PodsDFV.getValidationMessages()
in console, expect to see messageswidow.PodsDFV.formIsValid()
in console, expect truewindow.PodsDFV.getValidationMessages()
in console, expect not to see messagesChangelog text for these changes
getValidationMessages
method to window.podsDFVformIsValid
method to window.podsDFVPR checklist