-
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
Add a way to programmatically remove editor panels from UI #11802
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this outside of the persisted state?
I think yes, because: as you say—these panels being removed after a plugin that does so is uninstalled is very weird UX.
Really, they should be persisted changes if they were user-made changes (hiding the tag panel, etc.) but they shouldn't be persisted if a plugin made them (hiding the default tag panel to show a custom one).
Also: your testing instructions read like they'd make good E2E tests and this seems an important part of the UI we're modifying, so I think writing some E2E tests to confirm things work and revert as intended would be wise here.
7cca809
to
7707607
Compare
It feels weird to me that we have
It's a shame that there's no way to ask React if I had a similar problem with I'm struggling to think of a nice way around this. Perhaps need to bite the bullet and move away from having
Not persisting it makes sense to me. |
7707607
to
03e99bb
Compare
@tofumatt, I added e2e test with 03e99bb.
Now I that have e2e and unit tests in place, I can refactor store to avoid persistence layer. It looks like there is common agreement that it's wrong :)
Agreed on this one, however, I didn't find a better way to distinguish between user's interaction which hides the panel and site owners willingness to never offer this panel to their users. If you have any ideas I'm happy to update PR.
Yeah, it should be a follow-up issue as it might be a lot of work for an extremely rare case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @noisysocks that it would be nice to consolidate these selectors or make them more consistently named, but I'm a bit short on ideas for it at the moment. They are expressing different ideas though; maybe it's fine 🤷♂️
At any rate, the tests and the code look good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me!
54fce2e
to
33b4cb3
Compare
Is there any way to add panels? And no, I don't want to add an old-school meta box or a separate plugin sidebar. |
You can always register your own sidebar with as many panels as you want. See: There is no way to add a panel to the Document Settings sidebar. |
@gziolo Thank you for that! I need exactly
But how can I apply it when none of my blocks are in use? It should be independent from the blocks. |
Never mind, I found a way. 😄 |
@gziolo are you planning to add a way to add panels to the Document Settings sidebar? |
@manuelmeister - it is still under consideration. It all depends how Phase 2 of Gutenberg evolves and what is going the full page editing look like. It will have the biggest impact on how we tackle this issue. At the moment, there is this consideration that adding more sections might conflict with the direction phase 2 might take. In particular, we don’t want UI to be locked down to the single sidebar area used by the majority plugins. @youknowriad, is there antyhing I missed? |
@gziolo If it is not yet possible to add a panel to the Document Settings sidebar, is it possible to "override" how a panel renders? |
It's not possible to add your own panel to the Document Settings as of today, however you can create your own sidebar: Some panel can be overridden as explained in:
@chrisvanpatten, @mkaz or @nosolosw - do you know if we have those examples grouped somewhere? |
Also worth noting that the A different approach we could take to improve docs is to group things together: using |
@gziolo The taxonomies link is very helpful. I have been able to use the example to add a random component there, but the existing term checklist I have a plugin that used to convert switch taxonomy checklists to radio buttons.... effectively limiting the selection to a single term. So I'm looking for a way to use all the parts of the hierarchical checklist, but switch input from a checkbox to a radio. |
@gziolo Is there an implemented example of this solution? I tried to enqueue this javascript only in edit.php by creating a plugin, but didn't work. |
There is a corresponding e2e test which covers it: gutenberg/packages/e2e-tests/specs/sidebar.test.js Lines 108 to 134 in 6d3269e
You need to ensure that your plugin's script depends on |
@gziolo Works nice, tested using https://wordpress.stackexchange.com/a/339437/14546, but .. Eg.:
|
There is no way for doing it at the moment, we are discussing some possible ways of tackling it in #15450. There is also a related and more detailed issue where the same feature was requested: #6023. |
For a project of mine, the "pending review" is not needed and possibly bad for learning curve. Since removing 'Post & Visibility' is not working, is there another way to disable this "pending review" checkbox? |
Description
Closes #6225.
Related to #6533.
This PR addressed the following requests:
From @ecobux:
How has this been tested?
Execute the following code in the JS console to remove one of the panels and ensure it is not present in the sidebar and Options modal (you can access it from More Menu):
Note that you can't remove
Post & Visibility
panel. The following (despite being valid) won't be reflected in the UI:Screenshots
With all available panels completely removed:
With a few panels completely removed:
Known issues
@noisysocks I would appreciate your help here:
When you remove all panels, the section title is still there. Is there an easy way to hide it, too? I know I could use CSS but I would prefer to do it properly :)
Another thing I'm not happy about is that this setting persists. I think this could cause some issues when someone uninstalls a plugin which would use this feature as marked panels would remain removed. Should we move this outside of the persisted state?
Types of changes
New feature (non-breaking change which adds functionality for backwars compatibility).
Checklist: