Skip to content

Commit

Permalink
remove disable publish button
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Jun 29, 2023
1 parent 31c5acb commit 65cee5b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/required/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ import { useEffect, useRef } from '@wordpress/element';
import { v4 as uuidv4 } from 'uuid';
import { store as editorStore } from '@wordpress/editor';


export const Required = ({ value, children }) => {
const { current: componentId } = useRef( uuidv4() );
const { lockPostSaving, unlockPostSaving } = useDispatch( editorStore );

const {
lockPostSaving,
unlockPostSaving,
} = useDispatch( editorStore );

// Disable post saving when required field(s) are empty.
useEffect( () => {
if ( ! value ) {
lockPostSaving( componentId );
} else {
unlockPostSaving( componentId );
}

return () => unlockPostSaving( componentId );
return () => {
unlockPostSaving( componentId );
}
}, [ value ] );

return children;
Expand Down

0 comments on commit 65cee5b

Please sign in to comment.