I’ve been working on a project that started as 1.16 as a REST API. We’re in the process of adding UIs and with all the changes to in 1.7, we opted to use the release candidate since we can take advantage of things like verified routes now. (I suspect it’ll be production ready before we are, lol.)
1.7 changes things about layouts and I’m trying to make sure I both understand things and want to clear up my own confusion about others.
So far as I can tell, in the “live” portion of a LiveView, layout precedence happens as follows:
- An option in
on_mount
. So,{:ok, socket, layout: ...}
- An option in the router with
live_session :default, layout: ...
- An option in
use Phoenix.LiveView, layout: ...
With the design we’re going with, I would actually like to specify the layouts in the router within the context of a live_session
. I can reuse LiveViews in different contexts with different layouts. This is actually really, really slick for how we’re building some things.
The trouble I’m running into at the moment, and I’m not sure if this is a bug or my own misunderstanding about live_session
, is this:
On the first render, a layout specified in live_session
is not used. It will fall back to whatever is specified in use Phoenix.LiveView, layout: ...
or the option set in on_mount
. Is the the intended behavior or do I need to post an issue?