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

Input bug in Firefox: Difficult to Set Focus in Input Textarea for "Start a Workflow" #2393

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
17 changes: 14 additions & 3 deletions src/lib/holocene/code-block.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
copy(e, content);
};

let editor: HTMLElement;
let editor: HTMLDivElement | null = null;
let view: EditorView;

const formatJSON = (jsonData: string): string => {
Expand Down Expand Up @@ -174,19 +174,30 @@
}
};

$: disabled = disabled || copyable;
function handleFocus() {
if (editor) {
editor.focus();
}
}
$: content, language, setView();
</script>

<div class="relative min-w-[80px] grow">
<div class="relative" tabindex={0} on:focus={handleFocus}>
<div
bind:this={editor}
class={className}
class={`rounded-x inline min-w-[80px] cursor-text ${className} ${
editable ? 'editable' : 'readOnly'
}`}
class:inline
contenteditable={editable}
data-testid={$$props.testId}
class:editable
tabindex={-1}
class:readOnly={!editable}
{...$$restProps}
/>

{#if copyable}
<CopyButton
{copyIconTitle}
Expand Down
1 change: 0 additions & 1 deletion src/lib/holocene/combobox/combobox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
export let label: string;
export let multiselect = false;
export let value: string | string[] = multiselect ? [] : undefined;
export let toggleLabel: string;
export let noResultsText: string;
export let disabled = false;
export let labelHidden = false;
Expand Down
20 changes: 14 additions & 6 deletions src/lib/holocene/input/input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@

let testId = $$props['data-testid'] || id;

function callFocus(input: HTMLInputElement) {
if (autoFocus && input) input.focus();
let inputRef: HTMLInputElement | null = null;

function handleFocus() {
if (autoFocus && !disabled) {
inputRef?.focus();
}
}

const dispatch = createEventDispatcher();
Expand All @@ -100,36 +104,40 @@
class:unroundLeft={unroundLeft || $$slots['before-input']}
class:unroundRight={unroundRight || $$slots['after-input']}
class:invalid={!valid}
tabindex={disabled ? undefined : 0}
on:focus={handleFocus}
>
{#if icon}
<span class="icon-container">
<Icon name={icon} />
</span>
{/if}

<input
bind:this={inputRef}
class="input"
class:disabled
{disabled}
data-lpignore="true"
data-1p-ignore="true"
maxlength={maxLength > 0 ? maxLength : undefined}
{placeholder}
{id}
{name}
{spellcheck}
{required}
{autocomplete}
data-lpignore="true"
data-1p-ignore="true"
bind:value
on:click|stopPropagation
on:input
on:keydown|stopPropagation
on:change
on:focus
on:blur
use:callFocus
data-testid={testId}
{...$$restProps}
/>

{#if copyable}
<div class="copy-icon-container">
<button aria-label={copyButtonLabel} on:click={(e) => copy(e, value)}>
Expand Down Expand Up @@ -185,7 +193,7 @@
<style lang="postcss">
/* Base styles */
.input-container {
@apply surface-primary relative box-border inline-flex h-10 w-full items-center rounded-lg border-2 border-subtle text-sm focus-within:outline-none focus-within:ring-4 focus-within:ring-primary/70;
@apply surface-primary relative box-border inline-flex h-10 w-full cursor-text items-center rounded-lg border-2 border-subtle text-sm focus-within:outline-none focus-within:ring-4 focus-within:ring-primary/70;

&.error,
&.invalid {
Expand Down
Loading