Skip to content

Commit

Permalink
feat: Section and IFrame implements HasAriaLabel (#18590)
Browse files Browse the repository at this point in the history
Fixes #17876
  • Loading branch information
jcgueriaud1 committed Feb 2, 2024
1 parent 2c6d036 commit f8f74e6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.vaadin.flow.component.html;

import com.vaadin.flow.component.HasAriaLabel;
import com.vaadin.flow.component.HtmlComponent;
import com.vaadin.flow.component.PropertyDescriptor;
import com.vaadin.flow.component.PropertyDescriptors;
Expand All @@ -35,7 +36,7 @@
* Inline Frame element</a>
*/
@Tag(Tag.IFRAME)
public class IFrame extends HtmlComponent {
public class IFrame extends HtmlComponent implements HasAriaLabel {

private static final PropertyDescriptor<String, String> srcDescriptor = PropertyDescriptors
.attributeWithDefault("src", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.vaadin.flow.component.ClickNotifier;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.HasAriaLabel;
import com.vaadin.flow.component.HasOrderedComponents;
import com.vaadin.flow.component.HtmlContainer;
import com.vaadin.flow.component.Tag;
Expand All @@ -29,7 +30,7 @@
*/
@Tag(Tag.SECTION)
public class Section extends HtmlContainer
implements ClickNotifier<Section>, HasOrderedComponents {
implements ClickNotifier<Section>, HasOrderedComponents, HasAriaLabel {

/**
* Creates a new empty section.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@ public void reload() throws Exception {

Mockito.verify(element).executeJs("this.src = this.src");
}

@Test
@Override
public void testHasAriaLabelIsImplemented() {
super.testHasAriaLabelIsImplemented();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ protected void addProperties() {

@Test
@Override
public void testHasOrderedComponents() {
super.testHasOrderedComponents();
public void testHasAriaLabelIsImplemented() {
super.testHasAriaLabelIsImplemented();
}

@Test
@Override
public void testHasAriaLabelIsNotImplemented() {
// For most assistive technology it's fine to use aria-label or
// aria-labelledby on the <nav>, and <main> elements but not
// on <footer>, <section>, <article>, or <header>.
// Source: https://www.w3.org/TR/using-aria/#label-support
super.testHasAriaLabelIsNotImplemented();
public void testHasOrderedComponents() {
// According to this article:
// https://www.scottohara.me/blog/2021/07/16/section.html
// aria-label and aria-labelled-by are the best way to provide an
// accessible name
super.testHasOrderedComponents();
}

}

0 comments on commit f8f74e6

Please sign in to comment.