mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
fix(frontend): crash when resetting DateSelect values
This commit is contained in:
parent
bfcfd91c4c
commit
65b0d24903
1 changed files with 10 additions and 1 deletions
|
|
@ -24,7 +24,16 @@ export const DateSelect: React.FC<DateSelectProps> = ({
|
|||
className="block appearance-none min-w-full md:win-w-0 md:w-1/4 bg-white border border-gray-400 hover:border-gray-500 p-2 rounded shadow leading-tight focus:outline-none focus:ring"
|
||||
type="date"
|
||||
value={formatDateForDateInput(value)}
|
||||
onChange={(e) => onChange(parseDateFromDateInput(e.target.value))}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === "") {
|
||||
// Firefox includes "reset" buttons in date inputs, which set the value to "",
|
||||
// is does not make sense to clear the value in our case.
|
||||
e.target.value = formatDateForDateInput(value);
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
onChange(parseDateFromDateInput(e.target.value));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue