DEV Community

Discussion on: Intercepting back button on mobile in Vue/Nuxt/Vuetify apps

Collapse
 
ehutch79 profile image
Eric Hutchinson

PLEASE DO NOT HIJACK THE USERS HISTORY BUTTONS.

Seriously. re-read your premise:

"We have designed a modal that confuses users into thinking they're on a new page. How do hijack their browser to make it at like it's on an actual different page?"

Why did you not consider the solutions of 'how do we make this not look like a new page', or 'why not just actually make this a new page on mobile devices'

rather than 'lets change how the browser works'

You could use the history api to add an entry for the current url with an anchor tag, avoiding hijacking the back button.

Collapse
 
lilianaziolek profile image
Lili Z

Interesting idea. Maybe you can show a full working example of how this would work, particularly the second suggestion (change history)?
I don't like the idea of creating two completely different flows between mobile (new page) and desktop (dialog) as it would quickly make the code unnecessarily complex.

Collapse
 
ehutch79 profile image
Eric Hutchinson

Why not just make it obvious that they're looking at a modal on mobile? Remove the confusion rather than coding around it.

Collapse
 
ehutch79 profile image
Eric Hutchinson

I'm not about to write a whole implementation, but here's some good base examples

developer.mozilla.org/en-US/docs/W...