-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add shortcut tooltips for main toolbar #6605
Changes from 1 commit
5be0ff4
3fca8d0
56389d6
a161ebc
90c3e90
f042a70
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 |
---|---|---|
|
@@ -25,14 +25,21 @@ class IconButton extends Component { | |
const classes = classnames( 'components-icon-button', className ); | ||
const tooltipText = tooltip || label; | ||
|
||
// Should show the tooltip if an explicit tooltip is passed | ||
// or if there's a label and the children are empty and the tooltip is not explicitely disabled | ||
const showTooltip = !! tooltip || | ||
// Should show the tooltip... | ||
const showTooltip = ( | ||
// if an explicit tooltip is passed or... | ||
!! tooltip || | ||
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. Any reason to use 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. No. I copied the previous code. |
||
// if there's a shortcut or... | ||
!! shortcut || | ||
( | ||
label && | ||
// if there's a label and... | ||
!! label && | ||
// the children are empty and... | ||
( ! children || ( isArray( children ) && ! children.length ) ) && | ||
// the tooltip is not explicitely disabled. | ||
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. "explicitely" should be "explicitly" 🙂 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. Ugh yes, I just copied from the previous comment. :) |
||
false !== tooltip | ||
); | ||
) | ||
); | ||
|
||
let element = ( | ||
<Button { ...additionalProps } aria-label={ label } className={ classes } focus={ focus }> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,17 @@ import { IconButton } from '@wordpress/components'; | |
import { withSelect, withDispatch } from '@wordpress/data'; | ||
import { compose } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { primaryShortcut } from 'utils/keycodes'; | ||
|
||
function EditorHistoryRedo( { hasRedo, redo } ) { | ||
return ( | ||
<IconButton | ||
icon="redo" | ||
label={ __( 'Redo' ) } | ||
shortcut={ primaryShortcut( 'Y' ) } | ||
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.
So this probably needs to be 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. 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. Sublime is probably an outlier because it's cross-platform and I think cares less about OS-specific stuff? Browsers are definitely all Makes sense Sublime does 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. Actually, I spoke too soon. Edge also supports 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. Linux works with 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. Okay. Wondering if we should still keep |
||
disabled={ ! hasRedo } | ||
onClick={ redo } | ||
className="editor-history__undo" | ||
|
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.
I find this style of commenting each conditional really useful, especially after working on a patch around https://github.com/WordPress/gutenberg/blob/master/editor/components/block-list/block.js#L425 👍🏻
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.
A nitpick is moving the "if" above might make more sense, eg:
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.
So move all "if"s? "Or if..."?
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.
I think moving the if to the top and ending each line with
or...
orand...
, along with the indentation, would make sense.But what you have already makes sense, I just think the wording could be tidied up a bit. If my suggestion is less clear than I could be wrong and should be ignored 😅
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.
I'd say it could be:
(Includes the lack of
!!
prefixes.)