-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
navigation-menu: apply colors correctly in edition mode #18172
Conversation
db093dc
to
8d5f3df
Compare
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.
Thanks for addressing this bug! Left a couple comments; the major issue here is with IE support 😢
packages/block-library/src/navigation-menu/block-colors-selector.js
Outdated
Show resolved
Hide resolved
@retrofox lets defer to @tellthemachines' review and replace the CSS vars with inline styles—I agree it's important we don't forget IE support. I mistakenly thought that was being fixed on #18150. |
Deferring to the review from @tellthemachines
I think that setting the background and font color only on the nav block (where it is configured using block attributes) and propagating it only through CSS to appropriate nav items would be the easiest way forward. Skipping the need to pass props between parent-child blocks (unexplored territory) and also skipping CSS vars. I think they would be best to do the job but the current support still includes IE11 so we need to make sure it works. To put code where my mouth is 😀https://jsfiddle.net/marek/54uvko21/ |
We could not have this feature available in IE, and move ahead implementing it using tools available in modern browsers. That means the actual button in the toolbar would not be available in IE. @shaunandrews @mtias |
8d5f3df
to
fc42e1f
Compare
👋 I've added some changes applying the styles in the navigation menu, instead of each item:
|
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.
This is now working on IE 🎉 🎉
I'm not able to preview most of the colours on the editor side though. This happens on all browsers and I think it's due to the inline styles not being applied as per my comment below.
Another slight issue that might pop up, depending on how theme styles are set, is the background colour not being applied to the submenu dropdowns:
It might be worth applying the inline styles to the submenu <ul>
s too.
Question: should the colours reset to default when switching themes? Right now it's not happening but colours don't always translate 100% from one theme to another, say if accent colour was set as background in one theme it doesn't necessarily stay set in another. I am also noticing some intermittent weirdness when setting custom colours and then switching themes. This happened with a green custom accent set in Twenty Nineteen, and then switching to Twenty Twenty:
b2629d8
to
0d45c85
Compare
@tellthemachines thanks for your comments here, and they make totally sense but I'd like to handle the front-end in a different PR. Make sense for you? |
The only front end issue I mentioned was the submenu styling one, the others are all affecting the editor experience. The main one is the previews for most of the default colour choices in the editor not working: I think this is happening because we are relying on classnames which have no CSS attached to them on the editor side, and we should be able to fix it by inlining the styles instead. That's what I was trying to say in my comment above, sorry if it wasn't clear. |
Thanks. Make sense. Sorry, you were; pretty clear. :-) |
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.
This is working much better now! Approving the PR, and let's tackle the remaining issues in follow-up PRs.
Apart from the styling bugs I mentioned previously, there are a couple of accessibility problems we need to fix:
- Each colour palette should be wrapped in a
fieldset
with alegend
instead of a plaindiv
with aspan
for a label, so that screen readers can read out those labels. - There's no way to close the dropdown once options are selected except for clicking outside or pressing Esc. Perhaps a close button would be useful?
Thanks @tellthemachines! @WunderBart Maybe one or both of those accessibility issues could be a good substitute for #18135 (comment)? |
Thank you very much for your help here. Let's create issues in order to avoid forgetting them. |
54d1d7e
to
4db493b
Compare
In case the theme doesn't support CSS classes.
4db493b
to
48d0193
Compare
This change introduced a regression in how selected items displayed by forcing |
Description
This PR
fixesimplements the following changes:Aa
text of the toolbar colors-selector button.These changes are implemented in the Editor Canvas. Let's handle the front-end in another PR.
Screenshots
before
![image](https://user-images.githubusercontent.com/77539/67900555-838dce00-fb43-11e9-96cf-84ee83cd7781.png)
after
![image](https://user-images.githubusercontent.com/77539/67900611-a3bd8d00-fb43-11e9-90d9-fc39567508fa.png)
Checklist: