Skip to content

Commit

Permalink
fix(corrections-modal): edge case of not saving un-added corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Takshil-Kunadia committed Feb 14, 2025
1 parent 08ac0a0 commit f1682bb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/other-scripts/corrections-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ const CorrectionsModal = () => {
}
}, [] );

// Send Corrections.
useEffect( () => {
if ( isSaving ) {
saveCorrections();
}
}, [ isSaving ]);

// Add a new correction to the list.
const saveCorrection = () => {
// Check if the correction is empty.
Expand Down Expand Up @@ -127,8 +134,7 @@ const CorrectionsModal = () => {

// Save all corrections.
const saveCorrections = async () => {
setIsSaving(true);
setSaveError(null);
setSaveError( null );

const payload = {
post_id: postId,
Expand Down Expand Up @@ -262,7 +268,7 @@ const CorrectionsModal = () => {
variant="primary"
onClick={ () => {
saveCorrection();
saveCorrections();
setIsSaving( true );
} }
disabled={ isSaving }
>
Expand Down

0 comments on commit f1682bb

Please sign in to comment.