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

fix(gcds-textarea): Properly set value in shadow-root textarea #730

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

ethanWallace
Copy link
Collaborator

@ethanWallace ethanWallace commented Jan 9, 2025

Summary | Résumé

As mentioned in #685, the gcds-textarea value would not be properly reset when using Formgroup. After some investigation it was revealed this wasn't directly related to the Angular implementation of gcds-textarea and was just a bug within the web component.

When the component's value changes, the value was not properly being transferred to the textarea in the shadow-root of the component so the shadow-root textarea would keep the previous value while the rest of the component would register the new value.

How to test

Code example

      <gcds-textarea
        textarea-id="form-message"
        label="Message"
        hint="This is a hint."
        character-count="400"
        required
        id="text"
      ></gcds-textarea>

      <button type="button" onclick="resettextarea();">Reset textarea value</button>

      <script>
        function resettextarea() {
          let text = document.getElementById('text')
          text.value = '';
        }
      </script>

Instructions

Run through the instructions once on the main branch and then on this branch to see the fix.

  1. Add the code example to document.
  2. Type text into the gcds-textarea component.
  3. Click the reset button.
  4. On main branch, the textarea will still show the typed text in the textarea but the character count will be reset. On this branch, the textarea should no longer show any text in the textarea.

@ethanWallace ethanWallace changed the title fix(gcds-textarea): Properly set value in shadowroot textarea fix(gcds-textarea): Properly set value in shadow-root textarea Jan 9, 2025
Copy link
Collaborator

@melaniebmn melaniebmn left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the test instructions that was super helpful and good catch! :)

@ethanWallace ethanWallace merged commit c3f18e6 into main Jan 10, 2025
3 checks passed
@ethanWallace ethanWallace deleted the fix/reset-textarea-value branch January 10, 2025 13:18
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.

2 participants