Skip to content

Commit 8cfa0a5

Browse files
committed
Enable F mode for text input and toggle button
1 parent d757b26 commit 8cfa0a5

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

packages/ui/src/lib/components/Textbox.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import Icon from '$components/Icon.svelte';
3+
import { focusable } from '$lib/focus/focusable';
34
import { clickOutside } from '$lib/utils/clickOutside';
45
import { pxToRem } from '$lib/utils/pxToRem';
56
import { onMount, tick } from 'svelte';
@@ -176,6 +177,7 @@
176177
style:text-align={textAlign}
177178
bind:value
178179
bind:this={htmlInput}
180+
use:focusable={{ button: true }}
179181
{onclick}
180182
{onmousedown}
181183
oninput={(e) => {

packages/ui/src/lib/components/Toggle.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import { focusable } from '$lib/focus/focusable';
3+
24
interface Props {
35
small?: boolean;
46
disabled?: boolean;
@@ -36,6 +38,7 @@
3638
{value}
3739
{id}
3840
{disabled}
41+
use:focusable={{ button: true }}
3942
/>
4043

4144
<style lang="postcss">

packages/ui/src/lib/focus/fModeManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export class FModeManager {
178178
return;
179179
}
180180

181-
if (isInputElement(element)) {
181+
if (isInputElement(element) && element.type !== 'checkbox') {
182182
element.focus();
183183
} else {
184184
element.click();

packages/ui/src/lib/focus/focusUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function getNavigationAction(key: string): NavigationAction | null {
1212
return keyMap[key] ?? null;
1313
}
1414

15-
export function isInputElement(target: EventTarget | null): boolean {
15+
export function isInputElement(target: EventTarget | null): target is HTMLInputElement {
1616
return (
1717
(target instanceof HTMLElement && isContentEditable(target)) ||
1818
target instanceof HTMLTextAreaElement ||

0 commit comments

Comments
 (0)