isomerpages / isomercms-backend

A static website builder and host for the Singapore Government
5 stars 1 forks source link

fix: send updated data back to client from all update pages endpoints #1193

Closed jacobkwan closed 7 months ago

jacobkwan commented 7 months ago

Problem

https://opengovproducts.slack.com/archives/CK68JNFHR/p1709007514442959?thread_ts=1708332491.637599&cid=CK68JNFHR

Fixes issue where users see warning modal even after saving changes

Closes [insert issue #]

Solution

  1. updating/saving/syncing state logic seems quite convoluted on the FE
  2. However, frontend is indeed updating editor content after the POST request returns (see useUpdatePageHook in EditPageLayout)
  3. issue is that /update endpoints are not returning the updated frontmatter and pageContent to the client

This seems like the simplest solution to fixing this bug, i.e returning updated pageContent to the client, but would be good to refactor/simplify the FE logic next time

Breaking Changes

Features:

Improvements:

Bug Fixes:

Before & After Screenshots

BEFORE:

AFTER:

Tests

  1. Go to Prod CMS, edit a page to leave trailing whitespace then save changes
  2. Click Back on the navbar -> should see the unsaved changes modal
  3. Go to Staging CMS, edit a page to leave trailing whitespace then save changes
  4. After saving, should see that trailing whitespace is removed from the editor (to match backend)
  5. Click Back on the navbar -> should not see the modal

Deploy Notes

New environment variables:

New scripts:

New dependencies:

New dev dependencies: