-
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
Navigation block: Fix some off canvas appender accessibility issues #47047
Changes from all commits
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 |
---|---|---|
@@ -1,48 +1,69 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useInstanceId } from '@wordpress/compose'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { forwardRef } from '@wordpress/element'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as blockEditorStore } from '../../store'; | ||
import Inserter from '../inserter'; | ||
|
||
export const Appender = forwardRef( ( props, ref ) => { | ||
const { hideInserter, clientId } = useSelect( ( select ) => { | ||
const { | ||
getTemplateLock, | ||
__unstableGetEditorMode, | ||
getSelectedBlockClientId, | ||
} = select( blockEditorStore ); | ||
export const Appender = forwardRef( | ||
( { nestingLevel, blockCount, ...props }, ref ) => { | ||
const instanceId = useInstanceId( Appender ); | ||
const { hideInserter, clientId } = useSelect( ( select ) => { | ||
const { | ||
getTemplateLock, | ||
__unstableGetEditorMode, | ||
getSelectedBlockClientId, | ||
} = select( blockEditorStore ); | ||
|
||
const _clientId = getSelectedBlockClientId(); | ||
const _clientId = getSelectedBlockClientId(); | ||
|
||
return { | ||
clientId: getSelectedBlockClientId(), | ||
hideInserter: | ||
!! getTemplateLock( _clientId ) || | ||
__unstableGetEditorMode() === 'zoom-out', | ||
}; | ||
}, [] ); | ||
return { | ||
clientId: getSelectedBlockClientId(), | ||
hideInserter: | ||
!! getTemplateLock( _clientId ) || | ||
__unstableGetEditorMode() === 'zoom-out', | ||
}; | ||
}, [] ); | ||
|
||
if ( hideInserter ) { | ||
return null; | ||
} | ||
if ( hideInserter ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="offcanvas-editor__appender"> | ||
<Inserter | ||
ref={ ref } | ||
rootClientId={ clientId } | ||
position="bottom right" | ||
isAppender={ true } | ||
selectBlockOnInsert={ false } | ||
shouldDirectInsert={ false } | ||
__experimentalIsQuick | ||
{ ...props } | ||
/> | ||
</div> | ||
); | ||
} ); | ||
const descriptionId = `off-canvas-editor-appender__${ instanceId }`; | ||
const description = sprintf( | ||
/* translators: 1: The numerical position of the block. 2: The level of nesting for the block. */ | ||
__( 'Append at position %1$d, Level %2$d' ), | ||
blockCount + 1, | ||
nestingLevel | ||
); | ||
|
||
return ( | ||
<div className="offcanvas-editor-appender"> | ||
<Inserter | ||
ref={ ref } | ||
rootClientId={ clientId } | ||
position="bottom right" | ||
isAppender={ true } | ||
selectBlockOnInsert={ false } | ||
shouldDirectInsert={ false } | ||
__experimentalIsQuick | ||
{ ...props } | ||
toggleProps={ { 'aria-describedby': descriptionId } } | ||
/> | ||
<div | ||
className="offcanvas-editor-appender__description" | ||
id={ descriptionId } | ||
> | ||
{ description } | ||
</div> | ||
</div> | ||
); | ||
} | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.offcanvas-editor__appender .block-editor-inserter__toggle { | ||
.offcanvas-editor-appender .block-editor-inserter__toggle { | ||
background-color: #1e1e1e; | ||
color: #fff; | ||
margin: $grid-unit-10 0 0 24px; | ||
|
@@ -14,6 +14,10 @@ | |
} | ||
} | ||
|
||
.offcanvas-editor-appender__description { | ||
display: none; | ||
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. Question: does not 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 think 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 for confirming. |
||
} | ||
|
||
.offcanvas-editor-list-view-tree-wrapper { | ||
max-width: 100%; | ||
overflow-x: auto; | ||
|
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 is a great idea ❤️