Closed talldan closed 4 months ago
Yes! At this moment we have a hotch potch of prefferences and settings that we read from various state places. It's always confusing to decide in which store to save UI related stuff and not all the stuff is in @wordpress/interface
.
While working on distraction free mode and recently on #46907 I've needed to make the UI behave differently based on one general toggle or situation and it was both times more complicated than expected. Also as #46907 shows the lack of such an API is an invitation to worse ideas :)
I'm wondering now whether commands (those used by the command center) might be the best way to do this, as they share the same set of concerns (focus management, history management, they're groupings of actions).
I guess the only change is that we would be able to call commands programatically, and not just from the command center UI, and that might have implications.
What problem does this address?
TLDR - it's too difficult to implement a button or a shortcut that opens up another specific part of the editor interface.
Long version: A common requirement in our editors (and really all applications) is a user action that opens up a specific part of the interface. Some examples:
At the moment the code to do this isn't always easy to write. It often involves:
This means a poor developer experience for many contributors, code with high bug-potential, and also the potential for bad practices like introducing incorrect dependencies.
What is your proposed solution?
TLDR - lets do something about it, what are some options? Below I present one.
Long version: I think it's worth discussing the qualities such an API should have, my thoughts are:
wordpress/components
rather than likewordpress/edit-post
).Based on that, the best thing I can think of is a signals style API, somewhat similar to the keyboard shortcuts API.
This kind of API isn't without problems, but I still think it could be an improvement over what Gutenberg has now.
Thoughts? What are some other options?
(cc @WordPress/gutenberg-core)