-
Notifications
You must be signed in to change notification settings - Fork 13
Fix DBCustomSelect form reset functionality #4853
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 7b610f8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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 |
Co-authored-by: mfranzke <[email protected]>
Co-authored-by: mfranzke <[email protected]>
Co-authored-by: mfranzke <[email protected]>
@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? |
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:
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 |
…ix-4724 # Conflicts: # showcases/e2e/home/showcase-home.spec.ts
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Pull request was converted to draft
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
onUpdate
hookstate._values = []
and callsprops.onOptionSelected([])
on resetFeedback 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