Sanjibukai

Sanjibukai

Hello everybody,

I have an application where I have many LiveComponents within the same Liveview and the same route/url.
So I’m managing manually all the steps and states of components..

Now I have a use case where I can display a TOS in full page like a modal from any LiveComponent.
I could have managed it the same way (though it’s a bit overwhelming to manage all the steps manually)..
But I wanted to let the user be able to dismiss the TOS using it’s browser back button (particularly convenient for mobile with swipes).

So the only solution I found for that was to use a dedicated route and using live_patch so that I can come back to the previous route.

However, I just noticed that this trigger a whole new mounting, thus losing every state.

I precise that the TOS and the LiveComponents are within the same LiveView.
If I put a live_patch link to the previous route manually for testing purpose, I have the states kept correctly.

Now I can track manually every route/url of the pages where the user is before displaying the TOS so that I can redirect (with live_path) him back to where it was. But that will not solve the browser back button issue.

While I’m here isn’t there a way to keep track of the previous path by default in the socket?

Anyway, maybe I’m doing something wrong with how I organize my LiveView/LiveComponent..

How would you do that?

I’m thinking of going back to handle every view on theirs own routes but it was cool to have everything done in the same route (for related actions)

Showing Posts 1 to 2

Sanjibukai

Sanjibukai OP

Ok,

I figured out that I will need to push_patch Phoenix.LiveView — Phoenix LiveView v1.2.5 to be able to let the browser go back without mounting.

It’s very interesting…

paulstatezny

paulstatezny

By the way, I created an example Phoenix application to observe LiveView’s behavior for push_patch and push_redirect.

https://github.com/paulstatezny/live-view-back-button

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews