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
Accessibility: Improved keyboard accessibility in BarGauge #59382
Conversation
const { title } = this.props.value; | ||
const styles = getTitleStyles(this.props); | ||
|
||
if (!title) { | ||
return ( | ||
<div style={styles.wrapper} onClick={onClick} className={className}> | ||
<button style={styles.wrapper} onClick={onClick} className={cx(clearButtonStyles(theme), 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.
<button style={styles.wrapper} onClick={onClick} className={cx(clearButtonStyles(theme), className)}> | |
<button type='button' style={styles.wrapper} onClick={onClick} className={cx(clearButtonStyles(theme), className)}> |
This needs to have button
type to prevent the default submit behavior in forms, quite unlikely for this specific component, but better be safe.
); | ||
} | ||
|
||
return ( | ||
<div style={styles.wrapper} onClick={onClick} className={className}> | ||
<button style={styles.wrapper} onClick={onClick} className={cx(clearButtonStyles(theme), 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.
<button style={styles.wrapper} onClick={onClick} className={cx(clearButtonStyles(theme), className)}> | |
<button type='button' style={styles.wrapper} onClick={onClick} className={cx(clearButtonStyles(theme), 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.
ok couple of things to tackle here:
since onClick
is optional, this should only be a button
if there's an onClick
.
so the render function should probably look something like:
if (onClick) {
return (
<button type="button" style={styles.wrapper} onClick={onClick} className={cx(clearButtonStyles(theme), className)}>
{title && <div style={styles.title}>{title}</div>}
{this.renderBarAndValue()}
</button>
);
}
return (
<div style={styles.wrapper} className={className}>
{title && <div style={styles.title}>{title}</div>}
{this.renderBarAndValue()}
</div>
);
once we've done that, there's a couple of other issues:
- focus styles aren't appearing when tabbing (they're cut off by the outer panel having
overflow: hidden
) - panel links menu appears in the wrong place when using the keyboard (this isn't as much of a big deal tbh...)
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 only want it to be a button when there is an onClick
action right? Because with these changes, even if there is no onClick
, you can tab into the BarGauge
and when you hover over it there is a pointer icon.
This pull request was removed from the 9.3.0 milestone because 9.3.0 is currently being released. |
This pull request was removed from the 9.3.1 milestone because 9.3.1 is currently being released. |
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.
LGTM!
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.
think we need a different solution 🤔 not sure what tho... i'll do some digging
This reverts commit 9b83fa3.
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.
great job 🙌
…59653) Accessibility: Improved keyboard accessibility in BarGauge (#59382) * Accessibility: Improved keyboard accessibility in BarGauge * use appropriate elements when rendering bargauge * added space for focus-visible outline border * Revert "added space for focus-visible outline border" This reverts commit 9b83fa3. (cherry picked from commit d9f697b) Co-authored-by: Leo <108552997+lpskdl@users.noreply.github.com>
…rafana#59653) Accessibility: Improved keyboard accessibility in BarGauge (grafana#59382) * Accessibility: Improved keyboard accessibility in BarGauge * use appropriate elements when rendering bargauge * added space for focus-visible outline border * Revert "added space for focus-visible outline border" This reverts commit 9b83fa3. (cherry picked from commit d9f697b) Co-authored-by: Leo <108552997+lpskdl@users.noreply.github.com>
What is this feature?
Why do we need this feature?
Who is this feature for?
Which issue(s) does this PR fix?:
Fixes #59284
Special notes for your reviewer: