|
19 | 19 | import com.vaadin.flow.component.Component; |
20 | 20 | import com.vaadin.flow.component.CompositionNotifier; |
21 | 21 | import com.vaadin.flow.component.Focusable; |
| 22 | +import com.vaadin.flow.component.HasAriaLabel; |
22 | 23 | import com.vaadin.flow.component.HasLabel; |
23 | 24 | import com.vaadin.flow.component.HasHelper; |
24 | 25 | import com.vaadin.flow.component.HasSize; |
|
36 | 37 | import com.vaadin.flow.function.SerializableBiFunction; |
37 | 38 | import com.vaadin.flow.function.SerializableFunction; |
38 | 39 |
|
| 40 | +import java.util.Optional; |
| 41 | + |
39 | 42 | /** |
40 | 43 | * Internal class that provides base functionality for input field components, |
41 | 44 | * such as {@link TextField}. Not intended to be used publicly. |
|
47 | 50 | */ |
48 | 51 | public abstract class TextFieldBase<TComponent extends TextFieldBase<TComponent, TValue>, TValue> |
49 | 52 | extends AbstractSinglePropertyField<TComponent, TValue> |
50 | | - implements CompositionNotifier, Focusable<TComponent>, |
| 53 | + implements CompositionNotifier, Focusable<TComponent>, HasAriaLabel, |
51 | 54 | HasAutocapitalize, HasAutocomplete, HasAutocorrect, HasClearButton, |
52 | 55 | HasClientValidation, HasHelper, HasLabel, HasPrefixAndSuffix, HasSize, |
53 | 56 | HasStyle, HasTooltip, HasValidationProperties, HasValidator<TValue>, |
@@ -196,6 +199,32 @@ public boolean isRequired() { |
196 | 199 | return getElement().getProperty("required", false); |
197 | 200 | } |
198 | 201 |
|
| 202 | + @Override |
| 203 | + public void setLabel(String label) { |
| 204 | + HasLabel.super.setLabel(label); |
| 205 | + } |
| 206 | + |
| 207 | + @Override |
| 208 | + public void setAriaLabel(String ariaLabel) { |
| 209 | + getElement().setProperty("accessibleName", ariaLabel); |
| 210 | + } |
| 211 | + |
| 212 | + @Override |
| 213 | + public Optional<String> getAriaLabel() { |
| 214 | + return Optional.ofNullable(getElement().getProperty("accessibleName")); |
| 215 | + } |
| 216 | + |
| 217 | + @Override |
| 218 | + public void setAriaLabelledBy(String labelledBy) { |
| 219 | + getElement().setProperty("accessibleNameRef", labelledBy); |
| 220 | + } |
| 221 | + |
| 222 | + @Override |
| 223 | + public Optional<String> getAriaLabelledBy() { |
| 224 | + return Optional |
| 225 | + .ofNullable(getElement().getProperty("accessibleNameRef")); |
| 226 | + } |
| 227 | + |
199 | 228 | /** |
200 | 229 | * Adds the given components as children of this component at the slot |
201 | 230 | * 'prefix'. |
|
0 commit comments