-
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
Make tables accessible at high zoom levels #16324
Conversation
I know similar ideas to this have been previously explored (cc @jasmussen @mtias) without much success, and we'd really wanted to avoid the wrapper, but it does seem like it might be the only option. Just summarising some of the positives and negatives of the wrapping div: Pros:
Cons:
Looking at some other products:
|
// Fixed layout toggle | ||
&.has-fixed-layout { | ||
.has-fixed-layout { |
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.
Seeing some inconsistencies between the editor and the post when it comes to the fixed layout. The editor seems to wrap long text, but when viewing the post text isn't wrapped.
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.
Fixed 😅
align: true, | ||
}; | ||
|
||
const deprecated = [ |
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.
Would be great to add a test fixture for this deprecation. There are some examples of them in the folder with the fixtures (some have __deprecated
in the filename):
https://github.com/WordPress/gutenberg/tree/master/packages/e2e-tests/fixtures/blocks
It should just be a matter of grabbing the block HTML from master
(including the comment delimeters) and pasting it into a new html file, then regenerating the fixtures. If the deprecation works it'll output a valid block.
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.
Done, thanks for the reminder!
b28525d
to
d909d6a
Compare
Re some of @talldan 's pros and cons:
Overall, I'm still for making this change as in my opinion the usability benefits outweigh the costs. But look forward to hearing further discussion points 🙂 |
<Section type="body" rows={ body } /> | ||
<Section type="foot" rows={ foot } /> | ||
</table> | ||
<div className={ className }> |
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.
How about changing this to <figure>
, so the markup is clean, we can allow a caption, and it's the same as all our other media/figure blocks? Cc @talldan.
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.
Done!
Hi @tellthemachines! I don't really mind the changes here, it makes sense to support big tables and it looks good after a quick test. If we need a wrapping element, I think it should be |
*/ | ||
import { RichText, getColorClassName } from '@wordpress/block-editor'; | ||
|
||
const blockAttributes = { |
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.
We're only adding a wrapper element right? Can't we share this attribute definition between files?
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.
Yes, thanks for pointing that out. Done!
|
||
td, | ||
th { | ||
word-break: break-all; |
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.
Why is this needed? Does it deserve a comment?
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.
Assuming we don't want tables to horizontally scroll when they are aligned, we need table content to break. Added comment.
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.
Looks good. Feedback on above comments would be nice. Looks like e2e and unit tests also need to be updated.
e09783f
to
f8d31dc
Compare
@tellthemachines thanks for working on this, works great! 🙂 A while ago, we've implemented a similar solution at Yoast, with some additional visual improvements. I'm not saying those are necessarily good for Gutenberg, but I'd like to hear your thoughts and have some design feedback /Cc @mapk. Conversation can continue also on closed issues/PRs 🙂 and if the proposed improvements get some consensus I'd like to open a follow-up issue. Basically, in our implementation we're trying to solve a few issues:
All these three things kick in only when there's not enough space to display the table entirely so there's some width/viewport JS calculation running behind the scenes. Screenshots: The table while scrolling horizontally and the scrollbar becomes visible: When there's enough space, all the visual indicators are not displayed: Any thoughts more than welcome! |
@@ -17,25 +28,30 @@ | |||
// The table element needs to be kept as display table | |||
// for table features to work reliably. | |||
display: table; | |||
|
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.
❤️
@talldan thanks, will comment there! |
Description
Partially fixes #15346
In order for wide tables to be scrollable at small breakpoints and/or high zoom levels, I have added a
<div>
wrapper to the table block markup, setting itsoverflow
toauto
.How has this been tested?
Tested at high zoom levels on Chrome, Firefox, Safari (Mac) and IE (Windows 7 and 10).
Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: