Improved a11y for Field feedback and Secure Phrase input (#10320)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
f60f7a19af
commit
0c1c3f1cde
5 changed files with 78 additions and 3 deletions
|
@ -289,12 +289,20 @@ export default class Field extends React.PureComponent<PropShapes, IState> {
|
|||
// Handle displaying feedback on validity
|
||||
let fieldTooltip;
|
||||
if (tooltipContent || this.state.feedback) {
|
||||
let role: React.AriaRole;
|
||||
if (tooltipContent) {
|
||||
role = "tooltip";
|
||||
} else {
|
||||
role = this.state.valid ? "status" : "alert";
|
||||
}
|
||||
|
||||
fieldTooltip = (
|
||||
<Tooltip
|
||||
tooltipClassName={classNames("mx_Field_tooltip", "mx_Tooltip_noMargin", tooltipClassName)}
|
||||
visible={(this.state.focused && forceTooltipVisible) || this.state.feedbackVisible}
|
||||
label={tooltipContent || this.state.feedback}
|
||||
alignment={Tooltip.Alignment.Right}
|
||||
role={role}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ export interface ITooltipProps {
|
|||
id?: string;
|
||||
// If the parent is over this width, act as if it is only this wide
|
||||
maxParentWidth?: number;
|
||||
// aria-role passed to the tooltip
|
||||
role?: React.AriaRole;
|
||||
}
|
||||
|
||||
type State = Partial<Pick<CSSProperties, "display" | "right" | "top" | "transform" | "left">>;
|
||||
|
@ -186,7 +188,7 @@ export default class Tooltip extends React.PureComponent<ITooltipProps, State> {
|
|||
style.display = this.props.visible ? "block" : "none";
|
||||
|
||||
const tooltip = (
|
||||
<div role="tooltip" className={tooltipClasses} style={style}>
|
||||
<div role={this.props.role || "tooltip"} className={tooltipClasses} style={style}>
|
||||
<div className="mx_Tooltip_chevron" />
|
||||
{this.props.label}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue