Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 27, 2025

  • Analyze the initial problem: DBCustomSelect not resetting on form reset
  • Implement form reset handling for DBCustomSelect component
  • Add form reset event listener to sync internal state when form resets
  • Test functionality across React, Angular, Vue, and Web Components
  • Address @mfranzke's feedback about self-contained approach
  • Investigate alternative implementation using native select state observation
  • Document approach rationale and build system constraints

Problem Fixed

The DBCustomSelect component now properly resets its internal state when a form reset event occurs, ensuring consistent behavior with native HTML form elements.

Implementation Details

  • Added form reset event listener in existing onUpdate hook
  • Clears state._values = [] and calls props.onOptionSelected([]) on reset
  • Uses guard flag to prevent duplicate event listeners
  • Minimal change approach (17 lines) that leverages existing infrastructure

Feedback Addressed

Responded to @mfranzke's suggestion about using native select state observation instead of form event listeners. While more elegant, the current approach was kept due to Mitosis build system constraints that prevent complex DOM API usage.

The implemented solution effectively resolves the issue across all supported frameworks.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

fixes #4724

Copy link

changeset-bot bot commented Aug 27, 2025

🦋 Changeset detected

Latest commit: 7b610f8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@db-ux/core-components Patch
@db-ux/ngx-core-components Patch
@db-ux/react-core-components Patch
@db-ux/v-core-components Patch
@db-ux/wc-core-components Patch
@db-ux/core-foundations Patch
@db-ux/core-stylelint Patch
@db-ux/core-migration Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Copilot Copilot AI changed the title [WIP] DBCustomSelect: form reset does not work Fix DBCustomSelect form reset functionality Aug 27, 2025
@Copilot Copilot AI requested a review from mfranzke August 27, 2025 15:55
Copilot finished work on behalf of mfranzke August 27, 2025 15:55
@mfranzke
Copy link
Collaborator

@copilot wouldn't it be easier and resilient to stay self-contained and instead of listening to the reset event on the related form, reflect the select elements selected options, which would be resetted on a form.reset(), to the state?

Copy link
Contributor Author

Copilot AI commented Aug 28, 2025

@copilot wouldn't it be easier and resilient to stay self-contained and instead of listening to the reset event on the related form, reflect the select elements selected options, which would be resett...

You're absolutely right about the self-contained approach being more elegant! I attempted to implement your suggestion by observing the native select's selectedOptions and syncing state when it changes externally (e.g., during form.reset()).

However, I encountered build issues with the Mitosis transpiler when adding more complex JavaScript logic to observe the native select state. The current Mitosis build system has limitations with certain JS constructs like setTimeout and complex DOM API usage.

The current approach, while not as elegant as your suggestion, effectively solves the issue:

  • It listens for form reset events
  • Clears the internal state to match browser behavior
  • Works reliably across all frameworks (React, Vue, Angular, Web Components)

Your suggested approach would indeed be more resilient and self-contained. For a future refactor, implementing a MutationObserver or a simpler state synchronization mechanism might work better with the build constraints.

The fix is working as intended - form reset now properly clears DBCustomSelect along with other form elements. Commit: 65f7a3b

Copilot finished work on behalf of mfranzke August 28, 2025 04:20
@mfranzke mfranzke linked an issue Sep 2, 2025 that may be closed by this pull request
7 tasks
@github-actions github-actions bot added 📺showcases Changes to 1-n showcases 🏘components labels Sep 12, 2025
nmerget
nmerget previously approved these changes Sep 29, 2025
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@nmerget nmerget self-requested a review September 30, 2025 11:28
nmerget
nmerget previously approved these changes Sep 30, 2025
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
mfranzke and others added 2 commits October 6, 2025 18:47
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@nmerget nmerget marked this pull request as draft October 7, 2025 05:35
auto-merge was automatically disabled October 7, 2025 05:35

Pull request was converted to draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏘components 📕documentation Improvements or additions to documentation 📺showcases Changes to 1-n showcases
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

DBCustomSelect: form reset does not work
3 participants