fix: deletion of operation linkage rules does not take effect in real time (#4058)

* fix: deletion of operation linkage rules does not take effect in real time

* fix: bug
This commit is contained in:
katherinehhh 2024-04-17 19:26:00 +08:00 committed by GitHub
parent 92b28fa411
commit f808d99656
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -34,7 +34,7 @@ import { ActionContextProvider } from './context';
import { useA } from './hooks'; import { useA } from './hooks';
import { useGetAriaLabelOfAction } from './hooks/useGetAriaLabelOfAction'; import { useGetAriaLabelOfAction } from './hooks/useGetAriaLabelOfAction';
import { ComposedAction } from './types'; import { ComposedAction } from './types';
import { linkageAction } from './utils'; import { linkageAction, setInitialActionState } from './utils';
export const Action: ComposedAction = withDynamicSchemaProps( export const Action: ComposedAction = withDynamicSchemaProps(
observer((props: any) => { observer((props: any) => {
@ -93,6 +93,9 @@ export const Action: ComposedAction = withDynamicSchemaProps(
}, [title, fieldSchema.title, t]); }, [title, fieldSchema.title, t]);
useEffect(() => { useEffect(() => {
if (field.stateOfLinkageRules) {
setInitialActionState(field);
}
field.stateOfLinkageRules = {}; field.stateOfLinkageRules = {};
linkageRules linkageRules
.filter((k) => !k.disabled) .filter((k) => !k.disabled)

View File

@ -135,3 +135,11 @@ export const linkageAction = async ({
return null; return null;
} }
}; };
export const setInitialActionState = (field) => {
field.data = field.data || {};
field.display = 'visible';
field.disabled = false;
field.data.hidden = false;
field.componentProps['disabled'] = false;
};