Skip to content

Commit fee6901

Browse files
web-padawanclaude
andcommitted
feat: add HasAriaRole to Card
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2444a56 commit fee6901

1 file changed

Lines changed: 2 additions & 24 deletions

File tree

  • vaadin-card-flow-parent/vaadin-card-flow/src/main/java/com/vaadin/flow/component/card

vaadin-card-flow-parent/vaadin-card-flow/src/main/java/com/vaadin/flow/component/card/Card.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.vaadin.flow.component.dependency.JsModule;
2929
import com.vaadin.flow.component.dependency.NpmPackage;
3030
import com.vaadin.flow.component.html.Span;
31+
import com.vaadin.flow.component.shared.HasAriaRole;
3132
import com.vaadin.flow.component.shared.HasThemeVariant;
3233
import com.vaadin.flow.component.shared.SlotUtils;
3334
import com.vaadin.flow.dom.Element;
@@ -41,7 +42,7 @@
4142
@NpmPackage(value = "@vaadin/card", version = "25.2.0-rc2")
4243
@JsModule("@vaadin/card/src/vaadin-card.js")
4344
public class Card extends Component implements HasSize,
44-
HasThemeVariant<CardVariant>, HasComponents, HasAriaLabel {
45+
HasThemeVariant<CardVariant>, HasComponents, HasAriaLabel, HasAriaRole {
4546

4647
private static final String MEDIA_SLOT_NAME = "media";
4748
private static final String TITLE_SLOT_NAME = "title";
@@ -340,29 +341,6 @@ public void addComponentAtIndex(int index, Component component) {
340341
}
341342
}
342343

343-
/**
344-
* Sets the ARIA role attribute on the card.
345-
*
346-
* @param role
347-
* the ARIA role, or {@code null} to clear
348-
*/
349-
public void setAriaRole(String role) {
350-
if (role == null) {
351-
getElement().removeAttribute("role");
352-
} else {
353-
getElement().setAttribute("role", role);
354-
}
355-
}
356-
357-
/**
358-
* Gets the ARIA role attribute of the card.
359-
*
360-
* @return an optional ARIA role of the card if no ARIA role has been set
361-
*/
362-
public Optional<String> getAriaRole() {
363-
return Optional.ofNullable(getElement().getAttribute("role"));
364-
}
365-
366344
private void doSetTitle(String title) {
367345
if (title == null) {
368346
getElement().removeProperty(CARD_TITLE_PROPERTY);

0 commit comments

Comments
 (0)