mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: autofocus on conditional inputs.
This commit is contained in:
1 parent
762f19e170
commit
de30de7b2f
6 files changed
+37
-4
No files matched your search
@@ -140,6 +140,7 @@
|
||||
<InputText
|
||||
id="taxId"
|
||||
label="Tax ID"
|
||||
autofocus
|
||||
placeholder="Tax ID"
|
||||
bind:value={taxId} />
|
||||
</div>
|
||||
|
||||
@@ -24,11 +24,17 @@
|
||||
let error: string;
|
||||
|
||||
onMount(() => {
|
||||
if (element && autofocus) {
|
||||
element.focus();
|
||||
if (autofocus) {
|
||||
addInputFocus();
|
||||
}
|
||||
});
|
||||
|
||||
export function addInputFocus() {
|
||||
if (element) {
|
||||
element.focus();
|
||||
}
|
||||
}
|
||||
|
||||
const handleInvalid = (event: Event) => {
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
@@ -40,7 +40,12 @@
|
||||
Apply Appwrite credits to your organization.
|
||||
|
||||
<FormList>
|
||||
<InputText placeholder="Promo code" id="code" label="Add promo code" bind:value={coupon} />
|
||||
<InputText
|
||||
placeholder="Promo code"
|
||||
id="code"
|
||||
autofocus
|
||||
label="Add promo code"
|
||||
bind:value={coupon} />
|
||||
</FormList>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
<InputNumber
|
||||
placeholder="Add budget cap"
|
||||
id="cap"
|
||||
autofocus
|
||||
label="Budget cap (USD)"
|
||||
bind:value={budget} />
|
||||
{/if}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { project } from '../../store';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
let passwordHistory = $project?.authPasswordHistory < 1 ? 5 : $project?.authPasswordHistory;
|
||||
let passwordHistoryEnabled = ($project?.authPasswordHistory ?? 0) !== 0;
|
||||
@@ -34,6 +35,14 @@
|
||||
trackError(error, Submit.AuthPasswordHistoryUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
let maxSessionInputField: InputNumber | null = null;
|
||||
|
||||
$: if (passwordHistoryEnabled && maxSessionInputField) {
|
||||
tick().then(() => {
|
||||
maxSessionInputField.addInputFocus();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updatePasswordHistoryLimit}>
|
||||
@@ -59,6 +68,7 @@
|
||||
min={1}
|
||||
id="max-session"
|
||||
label="Limit"
|
||||
bind:this={maxSessionInputField}
|
||||
disabled={!passwordHistoryEnabled}
|
||||
bind:value={passwordHistory} />
|
||||
</FormList>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { project } from '../../store';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
let isLimited = $project?.authLimit !== 0;
|
||||
let newLimit = isLimited ? $project?.authLimit : 100;
|
||||
@@ -41,6 +42,14 @@
|
||||
trackError(error, Submit.AuthLimitUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
let maxUsersInputField: HTMLInputElement | null = null;
|
||||
|
||||
$: if (isLimited && maxUsersInputField) {
|
||||
tick().then(() => {
|
||||
maxUsersInputField.focus();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
@@ -96,7 +105,8 @@
|
||||
class="input-text"
|
||||
max="10000"
|
||||
disabled={!isLimited}
|
||||
bind:value={newLimit} />
|
||||
bind:value={newLimit}
|
||||
bind:this={maxUsersInputField} />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Reference in new issue
Block a user