Skip to content

Commit 55ae428

Browse files
authored
feat: add support for HTML <abbr> element (#14882) (#22574)
Add native Vaadin Flow support for the HTML abbreviation element to improve accessibility and eliminate the need for custom workarounds. - Add ABBR constant to Tag interface - Create Abbr component extending HtmlContainer with ClickNotifier - Add comprehensive test suite via AbbrTest - Support for title attribute inherited from HtmlComponent The component provides three constructors for flexible usage: empty, text-based, and component-based initialization. Fixes #14882
1 parent 0f11e19 commit 55ae428

File tree

3 files changed

+98
-0
lines changed
  • flow-html-components/src
  • flow-server/src/main/java/com/vaadin/flow/component

3 files changed

+98
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.html;
17+
18+
import com.vaadin.flow.component.ClickNotifier;
19+
import com.vaadin.flow.component.Component;
20+
import com.vaadin.flow.component.HtmlContainer;
21+
import com.vaadin.flow.component.Tag;
22+
23+
/**
24+
* Component representing a <code>&lt;abbr&gt;</code> element.
25+
*
26+
* @author Vaadin Ltd
27+
*/
28+
@Tag(Tag.ABBR)
29+
public class Abbr extends HtmlContainer implements ClickNotifier<Abbr> {
30+
31+
/**
32+
* Creates a new empty abbreviation.
33+
*/
34+
public Abbr() {
35+
super();
36+
}
37+
38+
/**
39+
* Creates a new abbreviation with the given child components.
40+
*
41+
* @param components
42+
* the child components
43+
*/
44+
public Abbr(Component... components) {
45+
super(components);
46+
}
47+
48+
/**
49+
* Creates a new abbreviation with the given text.
50+
*
51+
* @param text
52+
* the text
53+
*/
54+
public Abbr(String text) {
55+
super();
56+
setText(text);
57+
}
58+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.html;
17+
18+
import org.junit.Test;
19+
20+
public class AbbrTest extends ComponentTest {
21+
// Actual test methods in super class
22+
23+
@Override
24+
protected void addProperties() {
25+
// Component defines no new properties
26+
}
27+
28+
@Test
29+
@Override
30+
public void testHasAriaLabelIsNotImplemented() {
31+
// Don't use aria-label or aria-labelledby on any other non-interactive
32+
// content such as p, legend, li, or ul, because it is ignored.
33+
// Source: https://www.w3.org/TR/using-aria/#label-support
34+
super.testHasAriaLabelIsNotImplemented();
35+
}
36+
}

flow-server/src/main/java/com/vaadin/flow/component/Tag.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
* Tag for an <code>&lt;a&gt;</code>.
3939
*/
4040
String A = "a";
41+
/**
42+
* Tag for an <code>&lt;abbr&gt;</code>.
43+
*/
44+
String ABBR = "abbr";
4145
/**
4246
* Tag for an <code>&lt;article&gt;</code>.
4347
*/

0 commit comments

Comments
 (0)