-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a pointer/hint in the settings tab informing the user about the …
…styles tab (#47670) * Show a pointer/hint in the settings tab informing the user about the styles tab * Add a spoken message when the notice is dismissed * Update margin around text and button * Remove spoken message * Rename to hint and add focus management code * Relabel dismiss button
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/block-editor/src/components/inspector-controls-tabs/settings-tab-hint.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button } from '@wordpress/components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { focus } from '@wordpress/dom'; | ||
import { useRef } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { close } from '@wordpress/icons'; | ||
import { store as preferencesStore } from '@wordpress/preferences'; | ||
|
||
const PREFERENCE_NAME = 'isInspectorControlsTabsHintVisible'; | ||
|
||
export default function InspectorControlsTabsHint() { | ||
const isInspectorControlsTabsHintVisible = useSelect( | ||
( select ) => | ||
select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true, | ||
[] | ||
); | ||
|
||
const ref = useRef(); | ||
|
||
const { set: setPreference } = useDispatch( preferencesStore ); | ||
if ( ! isInspectorControlsTabsHintVisible ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div ref={ ref } className="block-editor-inspector-controls-tabs__hint"> | ||
<div className="block-editor-inspector-controls-tabs__hint-content"> | ||
{ __( | ||
"Looking for other block settings? They've moved to the styles tab." | ||
) } | ||
</div> | ||
<Button | ||
className="block-editor-inspector-controls-tabs__hint-dismiss" | ||
icon={ close } | ||
iconSize="16" | ||
label={ __( 'Dismiss hint' ) } | ||
onClick={ () => { | ||
// Retain focus when dismissing the element. | ||
const previousElement = focus.tabbable.findPrevious( | ||
ref.current | ||
); | ||
previousElement?.focus(); | ||
setPreference( 'core', PREFERENCE_NAME, false ); | ||
} } | ||
showTooltip={ false } | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4ef110c
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.
Flaky tests detected in 4ef110c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4093103462
📝 Reported issues:
specs/editor/various/multi-block-selection.test.js