-
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
Decouple ComplementaryArea
and Panel
#40720
Comments
@mirka how does the plan above sound to you? |
Sounds good. This maybe obvious, but the only thing I'd add is that we'll want to add |
Not obvious at all! That would be the first instance of a component from Added to the original issue description 👌 |
My understanding is that any of the sidebars on the right of the editor are complementary areas. So that's:
I wasn't involved in the development, but I could take a couple of guesses at how this came about. For a start, Complementary Areas were definitely refactored out of the edit-post/editor package which originally had plugin areas. I'd imagine this misuse of components was there from the very early days of Gutenberg. And I think it was probably like that because the Panel components are quite opinionated and aren't very flexible. For example: only the document settings and block inspector components use |
Thank you @talldan for the insights — this was also our guess.
The It would be great if someone with a good understanding of Gutenberg's UI could take a close look at the
We could then understand what improvements can be made to the original |
Yes, it's used extensively (and correctly afaik) in the BlockInspector and the Document settings in the post editor. Also used by lots of plugins.
I think what I mentioned is pretty much the extent of the usage. The good thing is it would be relatively easy to see the outcome of any changes to ComplementaryArea. It's probably worth starting by trying to remove the broken styles and seeing what breaks. |
What problem does this address?
Initially flagged in #38934 (comment)
Currently, the
ComplementaryArea
andComplementaryAreaHeader
components from@wordpress/interface
use thePanel
component from@wordpress/component
in an incorrect way:ComplementaryAreaHeader
component uses thecomponents-panel__header
a few times to "borrow" the styles of thePanelHeader
component — this classname should be considered private and shouldn't be used this way.ComplementaryAreaHeader
also overrides styles associated to thecomponents-panel__header
classname — this is also an anti-patter that should be avoided. Internal component classnames should not be considered part of a component's public API, and therefore should be used outside of the component itself.ComplementaryArea
component renders aPanel
as a sibling ofComplementaryAreaHeader
. This may need further investigation, in order to understand what were the original intentions here.ComplementaryArea
component also heavily overriders thePanel
styles by using its private hardcoded classnames, completely defeating the purpose of using a component.What is your proposed solution?
I think that we should first understand what is the goal of
ComplementaryArea
(the way it's supposed to work AND look). Currently, the component usesPanel
in such hacky ways that it makes me wonder if thePanel
component is a good fit forComplementaryArea
at all — a few questions that might help with this investigation are:ComplementaryAreaHeader
to render aPanelHeader
component ? And consequently,ComplementaryArea
to render aPanel
as a sibling of a (de facto)PanelHeader
?Based on this investigation, I see two main alternative approaches:
Option A: Remove
Panel
fromComplementaryArea
, find an alternativeIn case we agree that
Panel
is not a good fit forComplementaryArea
, we could remove it completely (including all of the hardcoded classnames), and look at reimplementing those parts:ComplementaryArea
.Option B: Continue using
Panel
, but in a tidier, proper wayThis would be the option in case we think that
Panel
can fitComplementaryArea
's needs. The next steps, in this case, would be:Panel
component (that don't introduce breaking changes) that can benefitComplementaryArea
Panel
andPanelHeader
components inComplementaryArea
andComplementaryAreaHeader
, instead of re-using the hardcodedcomponents-panel__header
classnamePanel
components as much as possible. These overrides should be applied without using hardcoded classnames from thePanel
component.Regardless of which option we pick, we should finally add
ComplementaryArea
(and its subcomponents) to Storybook.The text was updated successfully, but these errors were encountered: