Issues and PRs related to this discussion:
What problem does this address?
Adding ariaLabel block support to a block makes it possible to set the aria-label attribute internally - it does not expose a UI for setting this attribute.
This attribute can be injected into a block HTML or theme template like this:
<!-- wp:navigation {"ref":1,"ariaLabel":"My Navigation"} /-->
<!-- wp:navigation {"ariaLabel":"<?php esc_attr_e( 'Privacy', 'mny-theme' ); ?>"} -->
<!-- wp:navigation-link {"label":"<?php esc_html_e( 'Privacy Policy', 'twentytwentyfour' ); ?>","url":"#"} /-->
<!-- wp:navigation-link {"label":"<?php esc_html_e( 'Terms and Conditions', 'twentytwentyfour' ); ?>","url":"#"} /-->
<!-- wp:navigation-link {"label":"<?php esc_html_e( 'Contact Us', 'twentytwentyfour' ); ?>","url":"#"} /-->
<!-- /wp:navigation -->
The schema for this support references the aria-label attribute on HTML elements, but dynamic blocks do not save HTML to the database, so when you edit and save the content or template, the aria-label value is lost because it cannot be referenced.
Especially for the Navigation block, i.e. nav element, the loss of aria-label attribute values is a big problem. We need to find a way to solve this problem.
What is your proposed solution?
The three approaches I can think of are:
1. Add ariaLabel "attribute" in addition to block support
The ariaLabel block support respects existing attribute definitions. By explicitly defining the ariaLabel attribute in a dynamic block, the value will not be lost as it will be preserved as part of the comment delimiter (Related discussion).
2. Extend block support
Currently, the value type of this block support is a boolean value. We may be able to extend this to allow us to decide how we want to reference the value. Something like this:
{
"name": "core/navigation",
"supports": {
"ariaLabel": "delimiter"
}
}
This approach was also attempted with anchor support (You can see the series of efforts at #51402.).
3. Change the block support schema
We could also change the block support schema itself, which means we always store values as part of the comment delimiter, rather than referencing the stored content.
This approach might require us to add a block deprecation to blocks that already have this block support, and it might affect developers who already use this block support.
In the past we've run into issues with broken blocks when changing the schema for anchor support. See #48232 for more details.
Other suggestions
Although not directly related to this support failure, it's also worth discussing whether we should expose a UI for editing the aria-label attribute by default.
cc @Mamaduka @fabiankaegy @afercia @carolinan @aaronrobertshaw @talldan
Issues and PRs related to this discussion:
ariaLabelblock support to the Tag Cloud block)What problem does this address?
Adding
ariaLabelblock support to a block makes it possible to set thearia-labelattribute internally - it does not expose a UI for setting this attribute.This attribute can be injected into a block HTML or theme template like this:
The schema for this support references the aria-label attribute on HTML elements, but dynamic blocks do not save HTML to the database, so when you edit and save the content or template, the
aria-labelvalue is lost because it cannot be referenced.Especially for the Navigation block, i.e. nav element, the loss of
aria-labelattribute values is a big problem. We need to find a way to solve this problem.What is your proposed solution?
The three approaches I can think of are:
1. Add ariaLabel "attribute" in addition to block support
The
ariaLabelblock support respects existing attribute definitions. By explicitly defining the ariaLabel attribute in a dynamic block, the value will not be lost as it will be preserved as part of the comment delimiter (Related discussion).2. Extend block support
Currently, the value type of this block support is a boolean value. We may be able to extend this to allow us to decide how we want to reference the value. Something like this:
{ "name": "core/navigation", "supports": { "ariaLabel": "delimiter" } }This approach was also attempted with anchor support (You can see the series of efforts at #51402.).
3. Change the block support schema
We could also change the block support schema itself, which means we always store values as part of the comment delimiter, rather than referencing the stored content.
This approach might require us to add a block deprecation to blocks that already have this block support, and it might affect developers who already use this block support.
In the past we've run into issues with broken blocks when changing the schema for anchor support. See #48232 for more details.
Other suggestions
Although not directly related to this support failure, it's also worth discussing whether we should expose a UI for editing the
aria-labelattribute by default.cc @Mamaduka @fabiankaegy @afercia @carolinan @aaronrobertshaw @talldan