mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-22 16:48:30 +02:00
Fix entering encryption key
https://feedback.yaak.app/p/encryption-feature-error
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type { FocusEvent, HTMLAttributes } from 'react';
|
import type { FocusEvent, HTMLAttributes, ReactNode } from 'react';
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
useCallback,
|
useCallback,
|
||||||
@@ -21,6 +21,7 @@ export type PlainInputProps = Omit<InputProps, 'wrapLines' | 'onKeyDown' | 'type
|
|||||||
type?: 'text' | 'password' | 'number';
|
type?: 'text' | 'password' | 'number';
|
||||||
step?: number;
|
step?: number;
|
||||||
hideObscureToggle?: boolean;
|
hideObscureToggle?: boolean;
|
||||||
|
labelRightSlot?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PlainInput = forwardRef<{ focus: () => void }, PlainInputProps>(function PlainInput(
|
export const PlainInput = forwardRef<{ focus: () => void }, PlainInputProps>(function PlainInput(
|
||||||
@@ -37,6 +38,7 @@ export const PlainInput = forwardRef<{ focus: () => void }, PlainInputProps>(fun
|
|||||||
label,
|
label,
|
||||||
labelClassName,
|
labelClassName,
|
||||||
labelPosition = 'top',
|
labelPosition = 'top',
|
||||||
|
labelRightSlot,
|
||||||
leftSlot,
|
leftSlot,
|
||||||
name,
|
name,
|
||||||
onBlur,
|
onBlur,
|
||||||
@@ -91,10 +93,11 @@ export const PlainInput = forwardRef<{ focus: () => void }, PlainInputProps>(fun
|
|||||||
|
|
||||||
// Force input to update when receiving change and not in focus
|
// Force input to update when receiving change and not in focus
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!focused) {
|
const isFocused = document.activeElement === inputRef.current;
|
||||||
|
if (defaultValue != null && !isFocused) {
|
||||||
regenerateFocusedUpdateKey();
|
regenerateFocusedUpdateKey();
|
||||||
}
|
}
|
||||||
}, [focused, regenerateFocusedUpdateKey, defaultValue]);
|
}, [regenerateFocusedUpdateKey, defaultValue]);
|
||||||
|
|
||||||
const id = `input-${name}`;
|
const id = `input-${name}`;
|
||||||
const commonClassName = classNames(
|
const commonClassName = classNames(
|
||||||
@@ -136,6 +139,7 @@ export const PlainInput = forwardRef<{ focus: () => void }, PlainInputProps>(fun
|
|||||||
visuallyHidden={hideLabel}
|
visuallyHidden={hideLabel}
|
||||||
required={required}
|
required={required}
|
||||||
help={help}
|
help={help}
|
||||||
|
rightSlot={labelRightSlot}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</Label>
|
</Label>
|
||||||
|
|||||||
Reference in New Issue
Block a user