Skip to content

Conversation

@ethanWallace
Copy link
Collaborator

@ethanWallace ethanWallace commented Nov 18, 2025

Summary | Résumé

Add attributes to match gcds-select behaviour to the HTML select to provide additional validation.

gcds-select has also been expanded to work with the HTML ValidityState to provide developers with more options when validating gcds-selects and new methods to check current validation state.

New properties/attributes

Property Attribute Description Type Default
autofocus autofocus If true, the select will be focused on component render boolean undefined
form form The ID of the form that the select field belongs to. string undefined
validity validity Read-only property of the select, returns a ValidityState object that represents the validity states this element is in. ValidityState undefined

New methods

Name Description Returns
checkValidity() Check the validity of gcds-select boolean
getValidationMessage() Get validationMessage of gcds-select string

cds-snc/design-gc-conception#2022

@ethanWallace ethanWallace requested a review from daine November 18, 2025 19:03
this.internals.setFormValue(null);
this.value = null;
}
console.log('value changed to: ', this.value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('value changed to: ', this.value);

@ethanWallace ethanWallace requested a review from daine November 25, 2025 15:19
/**
* If true, the select will be focused on component render
*/
@Prop({ reflect: true }) autofocus: boolean;
Copy link
Collaborator

@daine daine Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be optional too? And/or have an inferred default on declaration?

Suggested change
@Prop({ reflect: true }) autofocus: boolean;
@Prop({ reflect: true }) autofocus?: false;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the build fails when adding a ? to the autofocus property. Luckily the property is still marked as optional even if it doesn't have a ?

${args.disabled ? `disabled` : null}
${args.autocomplete ? `autocomplete="${args.autocomplete}"` : null}
${args.autofocus ? `autofocus` : null}
${args.form ? `form="${args.value}"` : null}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be

Suggested change
${args.form ? `form="${args.value}"` : null}
${args.form ? `form="${args.form}"` : null}

${args.disabled ? `disabled` : null}
${args.autocomplete ? `autocomplete="${args.autocomplete}"` : null}
${args.autofocus ? `autofocus` : null}
${args.form ? `form="${args.value}"` : null}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
${args.form ? `form="${args.value}"` : null}
${args.form ? `form="${args.form}"` : null}

@ethanWallace ethanWallace requested a review from daine November 26, 2025 13:02
Copy link
Collaborator

@daine daine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants