Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

va-statement-of-truth: reflect error prop in va-text-input for styling #1255

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

jamigibbs
Copy link
Contributor

@jamigibbs jamigibbs commented Aug 5, 2024

Chromatic

https://3065-statement-of-truth--65a6e2ed2314f7b8f98609d8.chromatic.com

Description

This update will make sure that the error prop is being reflected on to the va-text-input markup element in the DOM so that error styling will apply to it. It also cleans up the previous solution that is no longer necessary because of that update.

This will fix error styling inconsistencies reported in the issue below.

Closes department-of-veterans-affairs/vets-design-system-documentation#3065

Screenshots

Screenshot 2024-08-05 at 4 00 25 PM Screenshot 2024-08-05 at 4 01 03 PM

QA Checklist

  • Component maintains 1:1 parity with design mocks
  • Text is consistent with what's been provided in the mocks
  • Component behaves as expected across breakpoints
  • Accessibility expert has signed off on code changes (if applicable. If not applicable provide reason why)
  • Designer has signed off on changes (if applicable. If not applicable provide reason why)
  • Tab order and focus state work as expected
  • Changes have been tested against screen readers (if applicable. If not applicable provide reason why)
  • New components are covered by e2e tests; updates to existing components are covered by existing test suite
  • Changes have been tested in vets-website using Verdaccio (if applicable. If not applicable provide reason why)

Acceptance criteria

  • QA checklist has been completed
  • Screenshots have been attached that cover desktop and mobile screens

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

@jamigibbs jamigibbs added the patch Patch change in semantic versioning label Aug 5, 2024
@@ -54,7 +54,7 @@ export class VaTextInput {
/**
* The error message to render.
*/
@Prop() error?: string;
@Prop({ reflect: true }) error?: string;
Copy link
Contributor Author

@jamigibbs jamigibbs Aug 5, 2024

Choose a reason for hiding this comment

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

reflect will add the prop to the component's markup in the DOM which is how the error styles are applied.

Reference: https://stenciljs.com/docs/properties#reflect-properties-values-to-attributes-reflect

*/
componentDidRender() {
if (this.inputError) {
this.inputField.setAttribute('error', this.inputError);
Copy link
Contributor Author

@jamigibbs jamigibbs Aug 5, 2024

Choose a reason for hiding this comment

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

With the error prop now rendering as an attribute on the va-text-input component using reflect, this logic is no longer necessary.

@jamigibbs jamigibbs marked this pull request as ready for review August 5, 2024 21:02
@jamigibbs jamigibbs requested a review from a team as a code owner August 5, 2024 21:02
Copy link
Contributor

@powellkerry powellkerry left a comment

Choose a reason for hiding this comment

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

Good find! I now know about "reflect" :)

@jamigibbs jamigibbs merged commit fefcd5e into main Aug 6, 2024
8 checks passed
@jamigibbs jamigibbs deleted the 3065-statement-of-truth branch August 6, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Patch change in semantic versioning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Statement of Truth web component not updating error messages properly
2 participants