Skip to content

Form stale values fix - #12

Merged
pzocchi merged 5 commits into
mainfrom
form_stale_values_fix
Oct 8, 2026
Merged

pzocchi merged 5 commits into
mainfrom
form_stale_values_fix

Conversation

@paolo-projects

Copy link
Copy Markdown
Contributor

This pull request introduces improved test support and several enhancements to the CRUD components, focusing on more robust form handling, better user experience, and improved documentation. The most significant updates include adding Playwright and Vitest for testing, refining the form and input logic to avoid race conditions and ensure accurate validation, and updating the documentation to reflect these changes.

Testing and Documentation Improvements:

  • Added Playwright and Vitest as dev dependencies, along with related scripts (test, test:e2e) in package.json. Introduced a playwright.config.ts file to configure E2E testing, and updated the documentation in CONTRIBUTING.md to describe running and configuring tests. [1] [2] [3] [4] [5] [6]

Form and Input Handling Enhancements:

  • Improved the logic in RLCrudForm to prevent unnecessary re-initializations when the form fields and values have not changed, using deep content comparison and snapshots. This avoids wiping user input when parent components re-render. [1] [2]
  • Updated the required field validation logic to properly handle 0 as a valid value and ensure arrays are considered valid only if non-empty.
  • Ensured that field changes in forms and filters are rendered synchronously using flushSync, preventing UI race conditions where user input could be lost if events fire before React updates the state. [1] [2] [3] [4]

Dialog and Fetch Race Condition Fixes:

  • Modified RLCrud to prevent race conditions when fetching data or opening dialogs by tracking the latest fetch and dialog opening, ensuring only the most recent actions are reflected in the UI. Dialogs now use unique keys based on an incrementing counter to force remounts, and timers are properly managed to avoid stale state. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Component API Improvements:

  • Added a step property to RLCrudFormFieldType and RLCrudInputProps, passing it through to the underlying input for more precise control over numeric and date/time fields. [1] [2] [3] [4] [5]

Build and Distribution:

  • Changed the main entry point in package.json from the UMD bundle to the standard CommonJS bundle for improved compatibility.

- Implement comprehensive tests for RLCrudForm covering add/edit scenarios, validation, and side effects.
- Create tests for RLDatePicker to ensure it displays and updates date values correctly.
- Introduce tests for various input components (RLInput, RLNumberInput, RLTextArea) to validate their behavior with controlled values and user interactions.
- Add helper functions for managing text fields and simulating user input.
- Set up testing environment with Vitest and configure necessary settings for testing with Shoelace components.
…improve data handling; add step prop for number inputs and implement validation tests for required fields.
@paolo-projects
paolo-projects requested a review from pzocchi October 8, 2026 09:13
@pzocchi
pzocchi merged commit 8bc6715 into main Oct 8, 2026
2 checks passed
@pzocchi
pzocchi deleted the form_stale_values_fix branch October 8, 2026 10:32
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