-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use <Navigator> component on Inspector Controls "back" button UX #45884
Comments
That's a great opportunity to support dynamic screens in the "Navigator" component to avoid having to loop over all the blocks. cc @ciampo
|
Opened #45913 to track the "pattern matching" feature in What the estimated timeline for this feature? Just trying to understand how to prioritize this task |
Currently we're working on a Nav block experiment (which is what is driving this) which we're hoping to have finalised by the end of this month. If that experiment is successful in user testing then we'd be looking to merge the feature in WP 6.2. So ideally we'd need to have the panels system in place sufficiently in advance to allow us to implement in time 🙏 |
@youknowriad Can I confirm that looping over all the blocks' Obviously it will "work" but I assume in an ideal world we would have a system whereby the "parent" can be dynamically added to the stack as a new block becomes selected and the history (.etc) will all "just work". Am I understanding you correctly? |
@getdave yes, you're understanding correctly. Looping over blocks is how the global styles already work so it didn't prove problematic so far but It's not ideal in terms of performance and code quality. |
Just to bring some clarity on how Currently
Since all I guess we’re also using dynamic to refer to two separate features:
Looping over the tree of parent blocks in order to create all necessary Let's work on refining the requirements first, which will help us to understand exactly what changes need to be done to |
How is this different than a |
From what I understood, going from a block's controls to its parent block's controls is conceptually represented as a back navigation, which implies that the screen representing the parent block is the previous one in the history stack — and therefore we'd need to "prepopulate" Using Although I may definitely misunderstood some of the requirements — excuses in advance if that's the case :) |
I guess that's true but can we solve this by just making the navigator a bit more smart. Meaning that going from a path that looks like |
Also, why is it important to differentiate between going back and going forward? I guess it's just for the animation right? There's also a difference between:
In other words, maybe "going back" for the navigator as implemented today is just a shortcut to "go to parent" and if it simplifies things to "remove it", we should consider it? |
Currently there is a difference between going back and forward, related to the fact that the
Visually,
I think we had this conversation before. If I understand correctly, you're suggesting a new implementation where any navigation is a "push", and where the meaning of "back" of "forward" is only given by the direction of the animation. I don't think that's a good implementation for a few reasons:
|
I looked into implementing the In particular, needing to know the JSX structure upfront in order to implement the As far as I can tell, we also don't need to use the navigation history — all we need is an animation. With that in mind, below is all the code that is required to implement the animation itself using Framer Motion, as implemented in #46342.
Right now I've just configured an enter animation, but you could also configure an exit animation, and these can be triggered whenever a new block is selected by passing in the selectedBlockClientID as a key on With this implementation being so simple and being able to trigger these animations via prop updates, I'm not sure that we gain much by creating a hierarchy of panels and seemingly working against React for the purposes of getting an animation to work. With that in mind, I can see a benefit to creating a wrapper around Framer Motion to allow developers to configure their own enter and exit animations for their block inspectors, and perhaps the There may also be accessibility concerns with this approach I haven't considered, which, from my understanding, we can explore based on how the user tests go. Would love to hear any additional perspectives on this! |
@artemiomorales I found exactly the same issue when I tried to implement using Navigator. Square peg, round hole. What's the goal here? Introduce an animation. In that case - as you suggest - why do we need to "navigate" between panels in a hierarchy? I think the concern is that we'll be introducing a new animation but perhaps we can use CSS custom props or SaSS vars to ensure they are standardised? |
What's the issue here, can you clarify a bit more? For me it's not about recreating the animation, it's about a component that was created for a given purpose (which corresponds here) but it's not fulfilling its promise, so we might want to adapt it. |
@youknowriad From my memory (and @artemiomorales can confirm) it was because Navigator needs all the components to be (pre)rendered in a hierarchy so you can navigate between them. So in this case you'd have to render all the inspector controls for all the current block's ancestors. Then you can move backwards through the history. If you try and do things dynamically as it stands it's not possible. I think I tried rendering the current block and it's immediate parent only and then Navigating backwards. But the issue is once you navigate to the parent there is nowhere left to go. What we need is a means to dynamically generate the "next" parent upon navigate. @artemiomorales to confirm though as he's now closer to this than I am. |
So I agree that having "dynamic screens" like suggested on my comment above would be a great addition #45884 (comment) But Just noting that doing this:
This won't render all the inspector controls of all blocks, the In other words, yeah dynamic routes will be a great addition and optimization but doing navigation is already possible even for a long list of static paths. There are some subtle things about the "back" and the history though (mentioned in this comment #45884 (comment)) |
@youknowriad I've created a draft pull request to illustrate my current understanding of how to implement the Navigator and continue discussion. Namely, I believe we'd need to introduce a special use case for the Navigation blocks, as the logic of the Navigator runs contrary to how rendering is handled in the Block Inspector. I believe it may be possible to get the Navigator to work, but as noted in the pull request, we would also need to ensure this works well with block selection via the Document List view and canvas in addition to the off-canvas editor. Would be appreciative of any ideas, feedback, and insights! |
This might be worth revisiting now #47883 has merged. |
You beat me to it, @scruffian ! As Ben said, we've recently introduced:
I believe that these new features should suit your needs too :) |
@draganescu Did we decide on a next step here? I feel like you were looking into this. |
The next step is to actually do it :D I have not started any work on this so it's up for grabs. |
In #45852 (comment) we added a "back" button to the Inspector Controls within the Nav block offcanvas experiment.
This is currently implemented in a relatively simplistic fashion with a simple
<Button>
which selects the parent block if one is available.However, it would be preferable to mirror the same pattern as the Global Styles UI and utilise the
<Navigator>
component to create a hierarchy of panels with animation between each. This is likely more complex so should not be attempted unless the Offcanvas Nav experiment is approved, but it will produce a better UX.@talldan and @jorgefilipecosta both suggested this PR as inspiration.
The text was updated successfully, but these errors were encountered: