mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:38:29 +02:00
Fix Input ref timing, PairEditor initialization, and environment variable focus
This commit is contained in:
@@ -401,7 +401,7 @@ function EncryptionInput({
|
|||||||
setState({ fieldType: 'encrypted', security, value, obscured: true, error: null });
|
setState({ fieldType: 'encrypted', security, value, obscured: true, error: null });
|
||||||
// We're calling this here because we want the input to be fully initialized so the caller
|
// We're calling this here because we want the input to be fully initialized so the caller
|
||||||
// can do stuff like change the selection.
|
// can do stuff like change the selection.
|
||||||
setRef?.(inputRef.current);
|
requestAnimationFrame(() => setRef?.(inputRef.current));
|
||||||
},
|
},
|
||||||
onError: (value) => {
|
onError: (value) => {
|
||||||
setState({
|
setState({
|
||||||
|
|||||||
@@ -128,14 +128,19 @@ export function PairEditor({
|
|||||||
|
|
||||||
const initPairEditorRow = useCallback(
|
const initPairEditorRow = useCallback(
|
||||||
(id: string, n: RowHandle | null) => {
|
(id: string, n: RowHandle | null) => {
|
||||||
|
const isLast = id === pairs[pairs.length - 1]?.id;
|
||||||
|
if (isLast) return; // Never add the last pair
|
||||||
|
|
||||||
rowsRef.current[id] = n;
|
rowsRef.current[id] = n;
|
||||||
const ready =
|
const validHandles = Object.values(rowsRef.current).filter((v) => v != null);
|
||||||
Object.values(rowsRef.current).filter((v) => v != null).length === pairs.length - 1; // Ignore the last placeholder pair
|
|
||||||
|
// NOTE: Ignore the last placeholder pair
|
||||||
|
const ready = validHandles.length === pairs.length - 1;
|
||||||
if (ready) {
|
if (ready) {
|
||||||
setRef?.(handle);
|
setRef?.(handle);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[handle, pairs.length, setRef],
|
[handle, pairs, setRef],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ export async function editEnvironment(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let didFocusVariable = false;
|
||||||
|
|
||||||
toggleDialog({
|
toggleDialog({
|
||||||
id: 'environment-editor',
|
id: 'environment-editor',
|
||||||
noPadding: true,
|
noPadding: true,
|
||||||
@@ -48,8 +50,9 @@ export async function editEnvironment(
|
|||||||
<EnvironmentEditDialog
|
<EnvironmentEditDialog
|
||||||
initialEnvironmentId={environment?.id ?? null}
|
initialEnvironmentId={environment?.id ?? null}
|
||||||
setRef={(pairEditor: PairEditorHandle | null) => {
|
setRef={(pairEditor: PairEditorHandle | null) => {
|
||||||
if (focusId) {
|
if (focusId && !didFocusVariable) {
|
||||||
pairEditor?.focusValue(focusId);
|
pairEditor?.focusValue(focusId);
|
||||||
|
didFocusVariable = true;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user