-
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
Accessibility: Dismiss BlockMover tooltips on escape key press. #15578
Changes from 17 commits
ae832dc
dc86b93
9a61a03
861351c
ceae20d
62b163d
60bbc6c
8ae4d23
4379cf3
919831f
f0962b3
9741f77
ee9b1a5
0331775
67cfdf7
b23a066
2dfaf5b
10e7a32
a6f7be2
22ef4e2
68dd831
87321bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ function IconButton( props, ref ) { | |
// the children are empty and... | ||
( ! children || ( isArray( children ) && ! children.length ) ) && | ||
// the tooltip is not explicitly disabled. | ||
false !== tooltip | ||
tooltip !== false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Readability improvement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting that this will probably conflict with changes currently proposed in #19193 . Regardless if it's an improvement, I might suggest to remove it here, since it's not entirely relevant (or close in proximity) to the intended changes. |
||
) | ||
); | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -71,6 +71,11 @@ class Tooltip extends Component { | |||||
return; | ||||||
} | ||||||
|
||||||
// If pressed key is escape, no further actions are needed. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused by this. What actions have been taken at this point in the event handler when pressing Escape? |
||||||
if ( event.keyCode === 27 ) { // 27 is the keyCode for escape | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest to use the import { ESCAPE } from '@wordpress/keycodes';
// ...
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @aduth, updated this. |
||||||
return; | ||||||
} | ||||||
|
||||||
// Needed in case unsetting is over while delayed set pending, i.e. | ||||||
// quickly blur/mouseleave before delayedSetIsOver is called | ||||||
this.delayedSetIsOver.cancel(); | ||||||
|
@@ -90,6 +95,7 @@ class Tooltip extends Component { | |||||
|
||||||
render() { | ||||||
const { children, position, text, shortcut } = this.props; | ||||||
const { isOver } = this.state; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this changed? Technically it's a violation of the I might suggest it be put back where it was. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this back. |
||||||
if ( Children.count( children ) !== 1 ) { | ||||||
if ( 'development' === process.env.NODE_ENV ) { | ||||||
// eslint-disable-next-line no-console | ||||||
|
@@ -100,11 +106,12 @@ class Tooltip extends Component { | |||||
} | ||||||
|
||||||
const child = Children.only( children ); | ||||||
const { isOver } = this.state; | ||||||
return cloneElement( child, { | ||||||
onMouseEnter: this.createToggleIsOver( 'onMouseEnter', true ), | ||||||
onMouseLeave: this.createToggleIsOver( 'onMouseLeave' ), | ||||||
onMouseDown: this.createToggleIsOver( 'onMouseDown' ), | ||||||
onClick: this.createToggleIsOver( 'onClick' ), | ||||||
onKeyDown: this.createToggleIsOver( 'onKeyDown' ), | ||||||
onFocus: this.createToggleIsOver( 'onFocus' ), | ||||||
onBlur: this.createToggleIsOver( 'onBlur' ), | ||||||
children: concatChildren( | ||||||
|
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.
Could you explain this change?
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.
This PR is based on @afercia 's PR
Maybe @afercia might help here since I've iterated over his initial work?
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.
Honestly I can't remember why I made that change. That was one year ago 😬 Sorry!
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.
@aduth @afercia, FYI - I have reverted these changes.