-
Notifications
You must be signed in to change notification settings - Fork 68
Fix: accessibility of blocks #3593
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
Changes from 2 commits
f8064fa
333ee5c
d66876a
eba70a8
00ae0df
3f50faa
534372e
e668b4a
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,15 @@ import { | |||||||||||||||||||||||||||
| } from '~stackable/block-components' | ||||||||||||||||||||||||||||
| import { addFilter } from '@wordpress/hooks' | ||||||||||||||||||||||||||||
| import compareVersions from 'compare-versions' | ||||||||||||||||||||||||||||
| import { semverCompare } from '~stackable/util' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| addFilter( 'stackable.horizontal-scroller.save.scroller', 'stackable/3.19.0', version => { | ||||||||||||||||||||||||||||
| if ( semverCompare( version, '<', '3.19.0' ) ) { | ||||||||||||||||||||||||||||
| return {} | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return { tabIndex: 0 } | ||||||||||||||||||||||||||||
| } ) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| addFilter( 'stackable.horizontal-scroller.save.scroller', 'stackable/3.19.0', version => { | |
| if ( semverCompare( version, '<', '3.19.0' ) ) { | |
| return {} | |
| } | |
| return { tabIndex: 0 } | |
| } ) | |
| addFilter( 'stackable.horizontal-scroller.save.scroller', 'stackable/3.19.0', ( attrs, version ) => { | |
| if ( semverCompare( version, '<', '3.19.0' ) ) { | |
| return attrs | |
| } | |
| return { ...attrs, tabIndex: 0 } | |
| } ) |
🤖 Prompt for AI Agents
In src/block/horizontal-scroller/deprecated.js around lines 13 to 19, the filter
callback currently treats the first arg as version which mismatches WP
applyFilters signature and can cause spread errors if attrs is undefined; change
the function signature to (attrs, version) and return a merged object (e.g.,
Object.assign({}, attrs || {}, { tabIndex: 0 }) or equivalent) so attrs are
preserved and guarded before spreading, while keeping the semverCompare check on
version to conditionally set tabIndex.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,7 @@ export const Save = props => { | |
| { attributes.isDismissible && | ||
| <button | ||
| className="stk-block-notification__close-button" | ||
| { ...applyFilters( 'stackable.notification.save.close-button', props.version ) } | ||
|
||
| > | ||
| <SVGCloseIcon | ||
| width={ attributes.dismissibleSize || 16 } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ import classnames from 'classnames' | |||||||
| import striptags from 'striptags' | ||||||||
|
|
||||||||
| import { compose } from '@wordpress/compose' | ||||||||
| import { applyFilters } from '@wordpress/hooks' | ||||||||
|
|
||||||||
| export const Save = props => { | ||||||||
| const { className, attributes } = props | ||||||||
|
|
@@ -71,6 +72,7 @@ export const Save = props => { | |||||||
| aria-valuemax="100" | ||||||||
| aria-valuenow={ progressValue } | ||||||||
| aria-valuetext={ attributes.progressAriaValueText ? striptags( attributes.progressAriaValueText ) : undefined } | ||||||||
| { ...applyFilters( 'stackable.progress-circle.accessibility', attributes.progressAriaValueText, props.version ) } | ||||||||
|
||||||||
| { ...applyFilters( 'stackable.progress-circle.accessibility', attributes.progressAriaValueText, props.version ) } | |
| aria-label={ attributes.progressAriaValueText ? striptags( attributes.progressAriaValueText ) : undefined } | |
| { ...applyFilters( 'stackable.progress-circle.div-props', {}, props.version ) } |
Then in the deprecation
const addAriaLabel = ( props, version ) => {
// If from an old version, remove the aria-label
if ( oldVersion ) {
return {
...props,
'aria-label': undefined,
}
}
return props
}
addFilter( 'stackable.progress-circle.div-props', 'stackable/3.19.0', props, removeAriaLabel )
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.
Likely wrong attribute used for the “Slide %d of %d” label.
Using
attributes.ariaLabelPrevhere seems off; this should be a separate string (e.g.,ariaLabelSlideOf). This affects SR announcements.Apply this diff (adjust to the actual schema name if different):
📝 Committable suggestion
🤖 Prompt for AI Agents