1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 02:12:30 +01:00

fix withBlur types

This commit is contained in:
Mikael Finstad 2024-10-06 16:28:36 +02:00
parent 2378ca35b0
commit 3bba13ad42
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
4 changed files with 7 additions and 8 deletions

View File

@ -54,7 +54,7 @@ function ExportModeButton({ selectedSegments, style }: { selectedSegments: unkno
<Select
style={{ height: 20, ...style }}
value={effectiveExportMode}
onChange={withBlur((e) => onChange(e.target.value))}
onChange={withBlur((e) => onChange(e.target.value as ExportMode))}
>
<option key="disabled" value="" disabled>{t('Export mode')}</option>

View File

@ -1,6 +1,5 @@
import { memo } from 'react';
import { withBlur } from '../util';
import useUserSettings from '../hooks/useUserSettings';
import Switch from './Switch';
@ -9,7 +8,7 @@ function MovFastStartButton() {
const { movFastStart, toggleMovFastStart } = useUserSettings();
return (
<Switch checked={movFastStart} onCheckedChange={withBlur(toggleMovFastStart)} />
<Switch checked={movFastStart} onCheckedChange={toggleMovFastStart} />
);
}

View File

@ -1,6 +1,5 @@
import { memo } from 'react';
import { withBlur } from '../util';
import useUserSettings from '../hooks/useUserSettings';
import Switch from './Switch';
@ -9,7 +8,7 @@ function PreserveMovDataButton() {
const { preserveMovData, togglePreserveMovData } = useUserSettings();
return (
<Switch checked={preserveMovData} onCheckedChange={withBlur(togglePreserveMovData)} />
<Switch checked={preserveMovData} onCheckedChange={togglePreserveMovData} />
);
}

View File

@ -165,10 +165,11 @@ export function filenamify(name: string) {
return name.replaceAll(/[^\w.-]/g, '_');
}
export function withBlur(cb) {
return (e) => {
// eslint-disable-next-line space-before-function-paren
export function withBlur<T extends { target?: { blur?: () => unknown } | object }>(cb: (a: T) => void) {
return (e: T) => {
cb(e);
e.target?.blur();
if (e.target && 'blur' in e.target) e.target?.blur?.();
};
}