tegel icon indicating copy to clipboard operation
tegel copied to clipboard

fix(dropdown): tds dropdown reset method

Open ckrook opened this issue 4 months ago • 3 comments

Describe pull-request

This pull request addresses issues with the tds-dropdown component's reset() method. The following enhancements and fixes are included:

  • Fixed the reset() method to ensure it properly resets the dropdown component, including clearing the filter input when the filter functionality is enabled.

  • Modified the setValueAttribute() method so that it removes the value attribute when no value is selected, instead of setting it to the string "null"

  • Added unit tests to verify that the reset() method works

  • Updated the Storybook example to include a "Reset Dropdown" button

Issue Linking:

Choose one of the following options

  • Jira: Add ticket number after CDEP-3518:
    https://tegel.atlassian.net/jira/software/projects/CDEP/boards/1/backlog?selectedIssue=CDEP-3518&text=reset

  • GitHub: Issue 768: https://github.com/scania-digital-design-system/tegel/issues/766

How to test

  1. Go to Storybook.
  2. Navigate to dropdown component
  3. Select an Option.
  4. You will then be able to reset the Option by clicking the "Reset Dropdown" button
  5. The expected behaviour from clicking this button is to reset the selected options.

Checklist before submission

  • [x] I have added unit tests for my changes (if applicable)
  • [x] All existing tests pass
  • [x] I have updated the documentation (if applicable)
  • [x] Not breaking production behavior
  • [x] Behavior available in storybook with documented descriptions (if applicable)

Suggested test steps

  • [x] Browser testing (Chrome, Safari, Firefox)
  • [x] Keyboard operability
  • [x] Interactive elements have labels.
  • [x] Storybook controls
  • [x] Design/controls/props is aligned with other components
  • [x] Dark/light mode and variants
  • [x] Input fields – values should be displayed properly

Additional context

I can remove the "reset dropdown" button. But I think its good to have on the storybook page just to illustrate the reset functionality. What do you think?

ckrook avatar Oct 14 '24 07:10 ckrook