fix: add forceDisabled prop to Field component for improved disable logic

This commit is contained in:
faisolavolut 2025-03-07 09:47:41 +07:00
parent 32a24c9df1
commit 8222744683
1 changed files with 7 additions and 1 deletions

View File

@ -68,6 +68,7 @@ export interface FieldProps {
search?: "api" | "local";
visibleLabel?: boolean;
autoRefresh?: boolean;
forceDisabled?: boolean;
}
export const Field: React.FC<FieldProps> = ({
fm,
@ -99,6 +100,7 @@ export const Field: React.FC<FieldProps> = ({
pagination = true,
search = "api",
autoRefresh = false,
forceDisabled,
}) => {
let result = null;
const field = useLocal({
@ -135,7 +137,11 @@ export const Field: React.FC<FieldProps> = ({
search,
};
const is_disable =
disabled === false ? false : fm.mode === "view" ? true : disabled;
typeof forceDisabled === "boolean"
? forceDisabled
: fm.mode === "view"
? true
: disabled;
const error = fm.error?.[name];
useEffect(() => {
setTimeout(() => {