Skip to content

Commit

Permalink
feat: forms better compatibility with chrome autofill (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen authored Feb 8, 2024
2 parents 9827896 + 5a98e05 commit b13f24f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
15 changes: 12 additions & 3 deletions front/share/src/Form/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
export let on_change: ((v: string) => void) | null = null;
import css from "./forms.module.css";
$: empty = display_value === "";
$: text_lines = display_value.split("\n").length;
Expand All @@ -49,11 +51,18 @@
on_change?.(h);
}
import css from "./forms.module.css";
const mount = (el: HTMLInputElement | HTMLTextAreaElement) => {
setTimeout(() => {
if(el.value !== "") {
on_input(el.value);
}
}, 500)
}
</script>


{#if multiline}
<textarea class={css["forms-input"]} {maxlength} {rows} {autocomplete} {disabled} {readonly} value={display_value} on:input={event => on_input(event.currentTarget.value)} on:input />
<textarea use:mount class={css["forms-input"]} {maxlength} {rows} {autocomplete} {disabled} {readonly} value={display_value} on:input={event => on_input(event.currentTarget.value)} on:input />
{:else}
<input {type} class={css["forms-input"]} {min} {max} {step} {autocomplete} {disabled} {readonly} value={display_value} on:input={event => on_input(event.currentTarget.value)} on:input />
<input use:mount {type} class={css["forms-input"]} {min} {max} {step} {autocomplete} {disabled} {readonly} value={display_value} on:input={event => on_input(event.currentTarget.value)} on:input />
{/if}
3 changes: 3 additions & 0 deletions front/share/src/Form/Label.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
color: var(--blue);
}
:global(.field-container:not(.with-icon):has(:-webkit-autofill)) .label,
:global(.field-container:not(.with-icon):focus-within) .label,
:global(.field-container:not(.with-icon)) .full {
transform: translateY(-110%) scale(0.7);
transform-origin: 0 0;
}
:global(.field-container.with-icon:has(:-webkit-autofill)) .label,
:global(.field-container.with-icon:focus-within) .label,
:global(.field-container.with-icon) .full {
transform: translateX(-1.75rem) translateY(-110%) scale(0.7);
Expand Down
14 changes: 13 additions & 1 deletion front/share/src/Form/forms.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
display: block;
flex: 1;
width: 1rem; /* fix min-width issue */
min-width: 0;
border: 0;
outline: 0;
padding: 0.75rem;
min-width: 0;
background: transparent;
resize: none;
color: #000;
appearance: none;
}

.forms-input:-webkit-autofill,
.forms-input:-webkit-autofill:active,
.forms-input:-webkit-autofill:hover,
.forms-input:-webkit-autofill:focus {
font: inherit !important;
/* TODO: overriding of chrome font is not working */
appearance: none !important;
-webkit-text-fill-color: #000 !important;
-webkit-background-clip: text !important;
}
1 change: 1 addition & 0 deletions front/share/src/LoginDashboard/login-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
font-weight: 600;
position: relative;
transition: color 200ms ease;
border-radius: 0.25rem;
}

.login-page-button.sending {
Expand Down

0 comments on commit b13f24f

Please sign in to comment.