-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keyboard accessibility: Add a "Skip link" to jump back from the inspe…
…ctor to the selected block * Skip to selected block first pass. * Use withSelect. * Polish. * Proper CSS. * Rename and document getBlockWrapperDOMNode. * Use getBlockSelectionStart which also allows to simplify.
- Loading branch information
Showing
7 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
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
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
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,31 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { withSelect } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal Dependencies | ||
*/ | ||
import './style.scss'; | ||
import { getBlockFocusableWrapper } from '../../utils/dom'; | ||
|
||
const SkipToSelectedBlock = ( { selectedBlockUID } ) => { | ||
const onClick = () => { | ||
const selectedBlockElement = getBlockFocusableWrapper( selectedBlockUID ); | ||
selectedBlockElement.focus(); | ||
}; | ||
|
||
return ( | ||
selectedBlockUID && | ||
<button type="button" className="button editor-skip-to-selected-block" onClick={ onClick }> | ||
{ __( 'Skip to the selected block' ) } | ||
</button> | ||
); | ||
}; | ||
|
||
export default withSelect( ( select ) => { | ||
return { | ||
selectedBlockUID: select( 'core/editor' ).getBlockSelectionStart(), | ||
}; | ||
} )( SkipToSelectedBlock ); |
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,20 @@ | ||
.editor-skip-to-selected-block { | ||
position: absolute; | ||
top: -9999em; | ||
|
||
&:focus { | ||
height: auto; | ||
width: auto; | ||
display: block; | ||
font-size: 14px; | ||
font-weight: 600; | ||
padding: 15px 23px 14px; | ||
background: #f1f1f1; | ||
color: $blue-wordpress; | ||
line-height: normal; | ||
box-shadow: 0 0 2px 2px rgba(0,0,0,.6); | ||
text-decoration: none; | ||
outline: none; | ||
z-index: z-index( '.skip-to-selected-block' ); | ||
} | ||
} |
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