-
-
Notifications
You must be signed in to change notification settings - Fork 200
Description
Bug Report
Description:
There is a synchronization issue with data-bind:files. While the binding correctly updates the signal when files are selected, the reverse is not true for clearing data. Programmatically resetting the signal (e.g., $files = [] or $files.length = 0) empties the reactive state but fails to reset the native DOM element's value to "".
This results in a UI mismatch: the application state behaves as if no files are selected, but the browser's file input control still displays the previous file count (e.g., "2 files").
Reproduction Steps:
- Create an input with
data-bind:files. - Select single or multiple files using the browser dialog.
- Observe that the signal (e.g.,
$files) is correctly populated with file data. - Trigger an action that sets the signal to an empty array:
$files = [].
Reproduction Demo: https://codepen.io/jiajing2138/pen/MYeyGpY
Expected Behavior:
The $files signal should empty and the native file input should visually reset to "No file chosen" (effectively executing input.value = "").
Actual Behavior:
The $files signal empties correctly (evidenced by reactive elements hiding/clearing), but the native <input> element retains and displays the previous file count.
Datastar Version
v1.0.0-RC.7