Skip to content

Commit

Permalink
MMT-3953: Fix for User is encountering latency issue with Save and Pu…
Browse files Browse the repository at this point in the history
…blish (#1333)

* MMT-3953: Fix for User is encountering latency issue with Save and Publish
  • Loading branch information
cgokey authored Dec 13, 2024
1 parent 347c892 commit 27dcb05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions static/src/js/components/MetadataForm/MetadataForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,12 @@ const MetadataForm = () => {
variant: 'success'
})

if (type === saveTypes.save) {
// We still need to navigate to the new draft revision on save and publish
// even though we will end up navigating to the preview page. The reason
// being is because the publish mutation causes the cache to be cleared and as a
// result the draft is refetched.
if (type === saveTypes.save || type === saveTypes.saveAndPublish) {
// Navigate to current form? just scroll to top of page instead?

if (currentSection) navigate(`/drafts/${draftType}/${savedConceptId}/${currentSection}?revisionId=${savedRevisionId}`, { replace: true })

window.scroll(0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ describe('MetadataForm', () => {
const button = screen.getByRole('button', { name: 'Save & Publish' })
await user.click(button)

expect(navigateSpy).toHaveBeenCalledTimes(1)
expect(navigateSpy).toHaveBeenCalledTimes(2)
expect(navigateSpy).toHaveBeenCalledWith('/tools/T1000000-MMT')
})
})
Expand Down

0 comments on commit 27dcb05

Please sign in to comment.