Skip to content

Commit

Permalink
refactor: enable actions buttons when baseline correction options are…
Browse files Browse the repository at this point in the history
… changed
  • Loading branch information
hamed-musallam committed Sep 25, 2024
1 parent 3d3f43a commit c9cb939
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ export default function BaseLineCorrectionOptionsPanel(
control,
algorithm,
defaultAlgorithmSelectProps,
formState: { isDirty },
} = useBaselineCorrection(filter);

const { onChange: onLivePreviewFieldChange, ...livePreviewFieldOptions } =
register('livePreview');

const disabledAction = filter.value && !isDirty;

return (
<>
<StickyHeader>
Expand All @@ -60,6 +64,8 @@ export default function BaseLineCorrectionOptionsPanel(
handleSubmit((values) => handleApplyFilter(values))()
}
onCancel={handleCancelFilter}
disabledConfirm={disabledAction}
disabledCancel={disabledAction}
/>
</HeaderContainer>
</StickyHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function useBaselineCorrection(filter: Filter | null) {
filter?.value || {},
);

const { handleSubmit, control, register, reset } = useForm<
const { handleSubmit, control, register, reset, formState } = useForm<
AirplsOptions | PolynomialOptions
>({
defaultValues: values,
Expand Down Expand Up @@ -195,5 +195,6 @@ export function useBaselineCorrection(filter: Filter | null) {
submitHandler,
handleApplyFilter,
handleCancelFilter,
formState,
};
}

0 comments on commit c9cb939

Please sign in to comment.