Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions app/src/ModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,23 @@ const close = () => {
export const ModalContent = ({ map }: { map: any }) => {
const { pathname } = useLocation()
const autoOpenedModal = useRef(false)
const hasHandledStartupModal = useRef(false)
const initialPathname = useRef(pathname)

useEffect(() => {
const myModal = document.getElementById('my_modal_3')
if (!(myModal instanceof HTMLDialogElement)) {
return
}

if (map.info_open && pathname === ROOT_PATH && !myModal.open) {
myModal.showModal()
autoOpenedModal.current = true
return
if (!hasHandledStartupModal.current) {
hasHandledStartupModal.current = true

if (map.info_open && initialPathname.current === ROOT_PATH && !myModal.open) {
myModal.showModal()
autoOpenedModal.current = true
return
}
}

if (pathname !== ROOT_PATH && autoOpenedModal.current && myModal.open) {
Expand Down
14 changes: 14 additions & 0 deletions cypress/e2e/authentification/set-new-password.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ describe('Utopia Map Authentication Set New Password', () => {
cy.get('dialog#my_modal_3').should('not.have.attr', 'open')
})

it('should not open the startup info modal when returning to root after the initial reset route', () => {
cy.visit('/set-new-password?token=test-reset-token')
cy.wait('@getMap')

cy.contains('h2', 'Set new Password')
.parent()
.within(() => {
cy.contains('button', '✕').click()
})

cy.location('pathname').should('eq', '/')
cy.get('dialog#my_modal_3').should('not.have.attr', 'open')
})

it('should still open the startup info modal on the root route', () => {
cy.visit('/')
cy.wait('@getMap')
Expand Down
Loading