feat(select): add required prop

This commit is contained in:
giuliana
2025-01-23 11:46:33 +00:00
parent ed3788271b
commit 3f24a126bf

View File

@@ -196,6 +196,11 @@ export class Select implements ComponentInterface {
*/
@Prop({ mutable: true }) value?: any | null;
/**
* If `true`, the user must fill in a value before submitting a form.
*/
@Prop() required = false;
/**
* Emitted when the value has changed.
*
@@ -974,7 +979,7 @@ export class Select implements ComponentInterface {
}
private renderListbox() {
const { disabled, inputId, isExpanded } = this;
const { disabled, inputId, isExpanded, required } = this;
return (
<button
@@ -983,6 +988,7 @@ export class Select implements ComponentInterface {
aria-label={this.ariaLabel}
aria-haspopup="dialog"
aria-expanded={`${isExpanded}`}
aria-required={`${required}`}
onFocus={this.onFocus}
onBlur={this.onBlur}
ref={(focusEl) => (this.focusEl = focusEl)}