-
Notifications
You must be signed in to change notification settings - Fork 841
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
Improve EuiBasicTable caption #2782
Improve EuiBasicTable caption #2782
Conversation
Sorry time chime in only after you've put some time into this but, honestly, I'm not sure if there's much/any value in this sort of caption. Screen readers already have robust table navigation capabilities so describing the size of the table is usually already done natively. (This isn't the case for paginated tables but that requires a different solution outside of captions.) Also, this quickly breaks down when you have multiple tables on a page because the caption gives you no context for what's in it. I think the most useful default caption would be to list the column titles. Maybe something like But captions need to be overridable by implementing developers because the best captions will always usually be user supplied (until we can run sentiment analysis on tables). (For your example table here, something like |
@myasonik Can you distill that into what you'd like to see here? Specifically I agree that this is likely best served by the consuming engineer. My suggestion would be to:
That's a decent first step that allows folks to fix #2336 throughout Kibana, then we can consider this (and a couple other a11y required props) later in a holistic a11y breaking changes release in the future. |
I agree with 2 and 3 in your list. I think maybe an example will better explain why I prefer a list of column headers over a count of rows: Think of the
Option 1 is what EUI currently has. Option 2 is what I'm proposing. It's longer, for sure, but between those options, I think Option 2 is more clear. #2335 which you mention tackles a different problem all together. |
You also mention adding this to a future breaking change. Is that to suggest that we force consuming engineers to provide a caption? (I would be for that if that's what you're suggesting.) |
Correct. Ultimately, that's the real way to solve this one. This first phase just unblocks folks quickly. |
@snide This mean adding a new prop to |
It definitely doesn't hurt to mention it in there but I was going to say that I think the most important spot is the props documentation which you've already done 👍 @andreadelrio What do you think about changing the default to be column headers instead of number of rows? @barlowm you might have a good suggestion here for a default as you're the one that's been auditing all these tables |
@myasonik I've tried adding the names of columns as the default caption. Here's what I currently have: Note: I initially tried to use Let me know what you think. |
I see what you mean with something like that getting tricky... This isn't ideal but is maybe ok... @chandlerprall - I wonder if you can help out here. I'm foggy on the details now but I recall you showing me something hidden in EUI to get rendered text that we used for some a11y feature somewhere, I think... Could we use that here? |
@myasonik I think you're referencing this https://elastic.github.io/eui/#/utilities/inner-text I think we're getting too complicated here for what is still a fairly poor default. Let's remove the columns, leave it with the ability to set the caption manually and make a new issue to revisit this concept later. That unblocks folks. We can always get more complicated later. End of day the best, suggested option is to always write it manually. |
@myasonik I agree with Dave that this is getting too complicated. I've gone back to having the number of rows as the default caption. I changed it a little bit to remove the use of the word "below" (as you suggested). |
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.
Small docs issue. LGTM.
@@ -95,6 +95,12 @@ export const propsInfo = { | |||
required: false, | |||
type: { name: '(criteria: #Criteria) => void' }, | |||
}, | |||
tableCaption: { | |||
description: | |||
'Describes the content of the table. If not specified, the caption will be "Below is a table of {itemCount} items."', |
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.
Gonna want to adjust your docs copy to match your recent changes.
<EuiI18n | ||
token="euiBasicTable.tableDescription" | ||
default="{tableCaption}" | ||
values={{ | ||
tableCaption: tableCaption, | ||
}} | ||
/> |
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.
Is this necessary? Usually the consuming app handles translation if it wants it and passes in a translated string.
<EuiI18n | ||
token="euiBasicTable.tableDescription" | ||
default="This table contains {itemCount} rows out of {totalItemCount} rows." | ||
values={{ | ||
totalItemCount: pagination.totalItemCount, | ||
itemCount: items.length, | ||
}} | ||
/> | ||
); | ||
} else { | ||
captionElement = ( | ||
<EuiI18n | ||
token="euiBasicTable.tableDescription" | ||
default="This table contains {itemCount} rows." | ||
values={{ | ||
itemCount: items.length, | ||
}} | ||
/> |
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.
These 2 EuiI8n
s can't have the same token
value because they have different default
strings.
Just need to change one or both of their token
to something else, like euiBasicTable.tableDescriptionWithPagination
/euiBasicTable.tableDescriptionWithoutPagination
Thanks for adding this @andreadelrio 🍾 |
Fixes #2336
Summary
Improve
EuiBasicTable
caption to include the number of total rows when there's multiple pages.Previous caption
Below is a table of {itemCount} items.
New caption
Below is a table containing {itemCount} rows.
[There's only 1 page]Below is a table containing {itemCount} rows out of {totalItemCount}.
[When there's more than 1 page]Not sure what to do in the case shown below. Currently the caption for this table would be
Below is a table containing 0 rows
. Should we be doing something likeBelow is a table containing no data
instead? @myasonik what do you think?Fixes #2336
Checklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Checked in IE11 and Firefox- [ ] Props have proper autodocs- [ ] Added documentation examples- [ ] Checked for breaking changes and labeled appropriately