Skip to content
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

Fix: Clear Datetime Attribute #594

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/lib/elements/forms/inputDateTime.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export let showLabel = true;
export let optionalText: string | undefined = undefined;
export let id: string;
export let value = '';
export let value: string;
export let required = false;
export let nullable = false;
export let disabled = false;
Expand Down Expand Up @@ -35,6 +35,11 @@
error = element.validationMessage;
}

function handleInput(event: Event) {
const { value: currentValue } = event.currentTarget as HTMLInputElement;
value = currentValue || null;
}

let prevValue = '';
function handleNullChange(e: CustomEvent<boolean>) {
const isNull = e.detail;
Expand Down Expand Up @@ -64,12 +69,13 @@
{disabled}
{readonly}
{required}
{value}
step=".001"
autocomplete={autocomplete ? 'on' : 'off'}
type="datetime-local"
class="input-text"
bind:value
bind:this={element}
on:input={handleInput}
on:invalid={handleInvalid}
style:--amount-of-buttons={isNullable ? 2.75 : 1}
style:--button-size={isNullable ? '2rem' : '1rem'} />
Expand Down