Skip to content
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

[TextareaAutosize] Fix missing form label #17931

Closed
wants to merge 5 commits into from
Closed

[TextareaAutosize] Fix missing form label #17931

wants to merge 5 commits into from

Conversation

koshea
Copy link
Contributor

@koshea koshea commented Oct 18, 2019

When using a multiline TextField, the popular WAVE Accessibility tool is throwing an error about the hidden "Shadow input" missing a form label. This doesn't really matter as it is aria-hidden, but I suppose the logic could be that it should be there in case that visibility were to change. It would be great to clear the error, as the tool is popular with clients testing blindly for compliance.

You can see the error here: https://hlk21.csb.app/

https://material-ui.com/components/textarea-autosize/

2019-10-18-165303_904x614_scrot

I was not quick to determine the best practice for how to label this invisible input, so I am hardly going to argue if you change my proposed value.

@mui-pr-bot
Copy link

Details of bundle changes.

Comparing: 702cde3...55a4f6c

bundle Size Change Size Gzip Change Gzip
TextareaAutosize ▲ +28 B (+0.55% ) 5.09 kB ▲ +20 B (+0.95% ) 2.13 kB
@material-ui/core ▲ +28 B (+0.01% ) 348 kB ▲ +16 B (+0.02% ) 95.2 kB
TablePagination ▲ +28 B (+0.02% ) 140 kB ▲ +15 B (+0.04% ) 40.7 kB
TextField ▲ +28 B (+0.02% ) 122 kB ▲ +14 B (+0.04% ) 35.5 kB
@material-ui/core[umd] ▲ +28 B (+0.01% ) 307 kB ▲ +13 B (+0.01% ) 88.3 kB
FilledInput ▲ +28 B (+0.04% ) 73.2 kB ▲ +13 B (+0.06% ) 22.7 kB
InputBase ▲ +28 B (+0.04% ) 70.3 kB ▲ +13 B (+0.06% ) 22 kB
OutlinedInput ▲ +28 B (+0.04% ) 73.7 kB ▲ +13 B (+0.06% ) 22.9 kB
Input ▲ +28 B (+0.04% ) 72.1 kB ▲ +12 B (+0.05% ) 22.4 kB
Select ▲ +28 B (+0.02% ) 113 kB ▲ +12 B (+0.04% ) 33.6 kB
NativeSelect ▲ +28 B (+0.04% ) 76.4 kB ▲ +11 B (+0.05% ) 24 kB
@material-ui/lab -- 145 kB -- 45 kB
@material-ui/styles -- 51.8 kB -- 15.6 kB
@material-ui/system -- 15.7 kB -- 4.37 kB
AppBar -- 63.9 kB -- 19.9 kB
Avatar -- 62.7 kB -- 19.6 kB
Backdrop -- 67.7 kB -- 20.9 kB
Badge -- 65.4 kB -- 20.2 kB
BottomNavigation -- 62.4 kB -- 19.5 kB
BottomNavigationAction -- 75.3 kB -- 23.8 kB
Box -- 70.8 kB -- 21.4 kB
Breadcrumbs -- 68 kB -- 21.3 kB
Button -- 79.3 kB -- 24.5 kB
ButtonBase -- 73.8 kB -- 23.1 kB
ButtonGroup -- 64.2 kB -- 20 kB
Card -- 62.9 kB -- 19.6 kB
CardActionArea -- 74.9 kB -- 23.6 kB
CardActions -- 62 kB -- 19.3 kB
CardContent -- 62 kB -- 19.3 kB
CardHeader -- 65.1 kB -- 20.4 kB
CardMedia -- 62.4 kB -- 19.5 kB
Checkbox -- 81.6 kB -- 25.6 kB
Chip -- 70.6 kB -- 21.8 kB
CircularProgress -- 64.1 kB -- 20.1 kB
ClickAwayListener -- 3.85 kB -- 1.55 kB
Collapse -- 67.8 kB -- 20.9 kB
colorManipulator -- 3.83 kB -- 1.52 kB
Container -- 63.1 kB -- 19.6 kB
CssBaseline -- 57.6 kB -- 18 kB
Dialog -- 82.5 kB -- 25.6 kB
DialogActions -- 62.1 kB -- 19.4 kB
DialogContent -- 62.2 kB -- 19.4 kB
DialogContentText -- 64 kB -- 20 kB
DialogTitle -- 64.3 kB -- 20.1 kB
Divider -- 62.6 kB -- 19.6 kB
docs.landing -- 54.8 kB -- 14.5 kB
docs.main -- 599 kB -- 191 kB
Drawer -- 84.3 kB -- 26 kB
ExpansionPanel -- 71.1 kB -- 22.1 kB
ExpansionPanelActions -- 62.1 kB -- 19.4 kB
ExpansionPanelDetails -- 61.9 kB -- 19.3 kB
ExpansionPanelSummary -- 77.9 kB -- 24.5 kB
Fab -- 76.7 kB -- 23.8 kB
Fade -- 23.1 kB -- 8.05 kB
FormControl -- 64.3 kB -- 19.9 kB
FormControlLabel -- 65.5 kB -- 20.5 kB
FormGroup -- 62 kB -- 19.3 kB
FormHelperText -- 63.3 kB -- 19.7 kB
FormLabel -- 63.3 kB -- 19.5 kB
Grid -- 65.1 kB -- 20.3 kB
GridList -- 62.5 kB -- 19.5 kB
GridListTile -- 63.7 kB -- 19.9 kB
GridListTileBar -- 63.2 kB -- 19.7 kB
Grow -- 23.7 kB -- 8.17 kB
Hidden -- 66.1 kB -- 20.6 kB
Icon -- 62.8 kB -- 19.6 kB
IconButton -- 76 kB -- 23.7 kB
InputAdornment -- 65.1 kB -- 20.4 kB
InputLabel -- 65.1 kB -- 20.2 kB
LinearProgress -- 65.3 kB -- 20.3 kB
Link -- 66.6 kB -- 21 kB
List -- 62.4 kB -- 19.3 kB
ListItem -- 77 kB -- 24 kB
ListItemAvatar -- 62.1 kB -- 19.4 kB
ListItemIcon -- 62.2 kB -- 19.4 kB
ListItemSecondaryAction -- 62 kB -- 19.3 kB
ListItemText -- 65 kB -- 20.4 kB
ListSubheader -- 62.8 kB -- 19.6 kB
Menu -- 88.3 kB -- 27.6 kB
MenuItem -- 78 kB -- 24.3 kB
MenuList -- 66 kB -- 20.6 kB
MobileStepper -- 67.7 kB -- 21.1 kB
Modal -- 14.3 kB -- 4.96 kB
NoSsr -- 2.19 kB -- 1.04 kB
Paper -- 62.4 kB -- 19.3 kB
Popover -- 82.6 kB -- 25.4 kB
Popper -- 28.3 kB -- 10.2 kB
Portal -- 2.87 kB -- 1.29 kB
Radio -- 82.5 kB -- 25.9 kB
RadioGroup -- 63.2 kB -- 19.7 kB
Rating -- 69.9 kB -- 22.3 kB
RootRef -- 4.43 kB -- 1.67 kB
Skeleton -- 62.5 kB -- 19.6 kB
Slide -- 25.1 kB -- 8.68 kB
Slider -- 75.4 kB -- 23.7 kB
Snackbar -- 77.1 kB -- 24 kB
SnackbarContent -- 65.8 kB -- 20.6 kB
SpeedDial -- 85.9 kB -- 27 kB
SpeedDialAction -- 115 kB -- 36.4 kB
SpeedDialIcon -- 64.6 kB -- 20.2 kB
Step -- 62.6 kB -- 19.6 kB
StepButton -- 82.2 kB -- 25.8 kB
StepConnector -- 62.7 kB -- 19.6 kB
StepContent -- 69 kB -- 21.4 kB
StepIcon -- 64.7 kB -- 20.1 kB
StepLabel -- 68.6 kB -- 21.4 kB
Stepper -- 64.9 kB -- 20.3 kB
styles/createMuiTheme -- 16.3 kB -- 5.79 kB
SvgIcon -- 63 kB -- 19.6 kB
SwipeableDrawer -- 90.7 kB -- 28 kB
Switch -- 80.8 kB -- 25.1 kB
Tab -- 76.2 kB -- 24.1 kB
Table -- 62.6 kB -- 19.5 kB
TableBody -- 62.1 kB -- 19.3 kB
TableCell -- 64.1 kB -- 20.1 kB
TableFooter -- 62.1 kB -- 19.3 kB
TableHead -- 62.1 kB -- 19.3 kB
TableRow -- 62.5 kB -- 19.5 kB
TableSortLabel -- 77.2 kB -- 24.4 kB
Tabs -- 85.3 kB -- 27.1 kB
ToggleButton -- 76 kB -- 24 kB
ToggleButtonGroup -- 63.2 kB -- 19.8 kB
Toolbar -- 62.3 kB -- 19.5 kB
Tooltip -- 99.1 kB -- 31.4 kB
TreeItem -- 73.4 kB -- 23.1 kB
TreeView -- 66 kB -- 20.6 kB
Typography -- 63.7 kB -- 19.8 kB
useMediaQuery -- 2.49 kB -- 1.05 kB
Zoom -- 23.1 kB -- 8.06 kB

Generated by 🚫 dangerJS against 55a4f6c

@oliviertassinari
Copy link
Member

I have created a support ticket on https://wave.webaim.org/feedback.

@oliviertassinari
Copy link
Member

Olivier -

aria-hidden is an invalid attribute on navigable elements such as form controls. If the element is navigable and/or has an input role, it cannot also be hidden. WAVE generally does not ignore errors on elements with aria-hidden because these typically are unhidden at some point (otherwise why would they be in the page at all).

Hopefully that's helpful.

Thanks,

Jared Smith
WebAIM.org

@oliviertassinari oliviertassinari added the component: TextareaAutosize The React component. label Oct 18, 2019
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have explored a couple of different approaches possible to avoid the need for a double textarea.
I can't find anything satisfactory. I have tried to inject a shadow textarea at each computation instead of permanent but it seems to trigger a layout of the whole page (even if we have position absolute :o).
Angular component caches the computation of the line-height.

@oliviertassinari oliviertassinari changed the title [TextareaAutosize] missing form label [TextareaAutosize] Fix missing form label Oct 19, 2019
@koshea
Copy link
Contributor Author

koshea commented Oct 19, 2019

What if instead we used aria-labelledby to indicate it shares labelling with the real input? The downside is we need an ID on the input. We could have the user provide one.

@oliviertassinari
Copy link
Member

What's the issue with the aria-label approach? Can a user see the second textarea?

@koshea
Copy link
Contributor Author

koshea commented Oct 19, 2019

Nope, I was just suggesting it may be more logical to indicate "this doesn't need a label because it is part of this" rather than give it this meaningless "hidden input". In the end I don't think any of this matters to the user, we are just dealing with a standard that wasn't written for this edge case.

@oliviertassinari
Copy link
Member

@koshea Did you have a look at https://github.com/OcelotChatbot/material-ui/pull/1?

koshea and others added 2 commits October 24, 2019 09:49
Co-Authored-By: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-Authored-By: Olivier Tassinari <olivier.tassinari@gmail.com>
@koshea
Copy link
Contributor Author

koshea commented Oct 24, 2019

@oliviertassinari I am good with your changes. The aria-hidden is unnecessary with the tabindex set. The text of the label does not really matter as it will never be read. I think this commit is worthwhile to avoid throwing the error in WAVE. 👍

I've tested in NVDA to confirm it is fine.

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for testing it.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A developer tool reporting an issue is no reason to change it here. We should fix this upstream because now:

  1. We have an additional element in the a11y tree that isn't interactive
  2. A non-localized label that can't be customized

Is there an actual existing issue with assistive technology?

aria-hidden is an invalid attribute on navigable elements such as form controls.

does not apply here since the element isn't navigable because it has a negative tabindex.

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 24, 2019

Yeah, I think that these are pur DX changes. I find the label description on the shadow textarea interesting because it yields some information on why it's needed for the developers. I find the fix of the errors reported by Wave interesting because remove the need for a developer to go check what's wrong with the element.
Do the changes have any downsides? For instance, if the shadow textarea can't be reached, does it need to have its label translated?

@eps1lon are you worried about the changes because it creates a precedent to work around accessibility tools, that it removes an incentive for them to double-check their logic and fix upstream?

@koshea
Copy link
Contributor Author

koshea commented Oct 25, 2019

@eps1lon my two cents is that WAVE is somewhere between a developer tool and a browser. It is almost like putting in a hack to support IE11, except with the slightest chance upstream will change their mind. Non-technical users in my industry use this tool to evaluate products for compliance (whether that is a good idea or not, it is reality), and basically if it is showing an error, they are unable to deploy the software.

At the end of the day I am just going to have to patch the library with this change which is a small nuisance. If you don't want to introduce this label, would you consider adding a shadowInputProps or something to be able to alter that component without patching?

@eps1lon
Copy link
Member

eps1lon commented Oct 25, 2019

My problem is that we don't have sufficient test coverage for assistive technology and the rationale provided here does not apply.

So from my viewpoint this change is neither tested sufficiently nor justified.

@oliviertassinari
Copy link
Member

@koshea If I understand your business case, your product is a widget integrated into your customer websites (schools). You fear to not convert potential customers because they use Wave and notice an error?

I have no objection for a shadowPropsprop.

@koshea
Copy link
Contributor Author

koshea commented Oct 25, 2019

@oliviertassinari yep, you got it. If @eps1lon is also open to the new prop, I will get the commit in.

@oliviertassinari
Copy link
Member

@koshea For the time being, you can perform DOM operations on the shallow element once the page mount. Thank you for raising this problem. I think that we will wait to have more user's feedback before moving forward.

@koshea
Copy link
Contributor Author

koshea commented Oct 29, 2019

Fair enough, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants