mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixes issues #7884
* Introduced a 'exclude' option in the 'Field' to exclude it from the change completely. Use the option 'exclude' to add field 'notNullColumns', which will be excluded from the data, but - can be used to force rerender the 'Not Null Columns' select control on change of it. * Fixed the linter issue * Rerender the cell as well, when dependent changes values. (#7884) * Listen for the depenent changes even for the non-visible controls * Use 'useRef' on every rendering to avoid the React 'Something wrong' page
This commit is contained in:
parent
92dd13e72a
commit
315d1a40a4
@ -70,7 +70,8 @@ export default function DataGridView({
|
|||||||
);
|
);
|
||||||
}, [refreshKey]);
|
}, [refreshKey]);
|
||||||
|
|
||||||
listenDepChanges(accessPath, field, options.visible, schemaState);
|
// We won't refresh the whole grid on dependent changes.
|
||||||
|
listenDepChanges(accessPath, field, schemaState);
|
||||||
|
|
||||||
if (!features.current) {
|
if (!features.current) {
|
||||||
features.current = new FeatureSet();
|
features.current = new FeatureSet();
|
||||||
|
@ -39,8 +39,13 @@ export function getMappedCell({field}) {
|
|||||||
);
|
);
|
||||||
let value = useFieldValue(colAccessPath, schemaState, subscriberManager);
|
let value = useFieldValue(colAccessPath, schemaState, subscriberManager);
|
||||||
let rowValue = useFieldValue(rowAccessPath, schemaState);
|
let rowValue = useFieldValue(rowAccessPath, schemaState);
|
||||||
|
const rerenderCellOnDepChange = (...args) => {
|
||||||
|
subscriberManager.current?.signal(...args);
|
||||||
|
};
|
||||||
|
|
||||||
listenDepChanges(colAccessPath, field, true, schemaState);
|
listenDepChanges(
|
||||||
|
colAccessPath, field, schemaState, rerenderCellOnDepChange
|
||||||
|
);
|
||||||
|
|
||||||
if (!field.id) {
|
if (!field.id) {
|
||||||
console.error(`No id set for the field: ${field}`);
|
console.error(`No id set for the field: ${field}`);
|
||||||
@ -93,9 +98,13 @@ export function getMappedCell({field}) {
|
|||||||
props.cell = 'unknown';
|
props.cell = 'unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const memDeps = [
|
||||||
|
...flatternObject(colOptions), value, row.index,
|
||||||
|
field?.deps?.map((dep) => rowValue[dep])
|
||||||
|
];
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => <MappedCellControl {...props}/>,
|
() => <MappedCellControl {...props}/>, memDeps
|
||||||
[...flatternObject(colOptions), value, row.index]
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,9 @@ export default function FieldSetView({
|
|||||||
|
|
||||||
const label = field.label;
|
const label = field.label;
|
||||||
|
|
||||||
listenDepChanges(accessPath, field, options.visible, schemaState);
|
listenDepChanges(
|
||||||
|
accessPath, field, schemaState, () => subscriberManager.current?.signal()
|
||||||
|
);
|
||||||
|
|
||||||
const fieldGroups = useMemo(
|
const fieldGroups = useMemo(
|
||||||
() => createFieldControls({
|
() => createFieldControls({
|
||||||
|
@ -133,7 +133,9 @@ export default function FormView({
|
|||||||
}
|
}
|
||||||
}, [isOnScreen]);
|
}, [isOnScreen]);
|
||||||
|
|
||||||
listenDepChanges(accessPath, field, visible, schemaState);
|
listenDepChanges(
|
||||||
|
accessPath, field, schemaState, () => subscriberManager.current?.signal()
|
||||||
|
);
|
||||||
|
|
||||||
// Upon reset, set the tab to first.
|
// Upon reset, set the tab to first.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -28,8 +28,9 @@ export default function InlineView({
|
|||||||
const { visible } =
|
const { visible } =
|
||||||
accessPath ? useFieldOptions(accessPath, schemaState) : { visible: true };
|
accessPath ? useFieldOptions(accessPath, schemaState) : { visible: true };
|
||||||
|
|
||||||
|
// We won't rerender the InlineView on changes of the dependencies.
|
||||||
if (!accessPath || isPropertyMode)
|
if (!accessPath || isPropertyMode)
|
||||||
listenDepChanges(accessPath, field, visible, schemaState);
|
listenDepChanges(accessPath, field, schemaState);
|
||||||
|
|
||||||
// Check whether form is kept hidden by visible prop.
|
// Check whether form is kept hidden by visible prop.
|
||||||
// We don't support inline-view in 'property' mode
|
// We don't support inline-view in 'property' mode
|
||||||
|
@ -363,8 +363,7 @@ export const MappedFormControl = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const depVals = listenDepChanges(
|
const depVals = listenDepChanges(
|
||||||
accessPath, field, options.visible, schemaState, state,
|
accessPath, field, schemaState, avoidRenderingWhenNotMounted
|
||||||
avoidRenderingWhenNotMounted
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let newProps = {
|
let newProps = {
|
||||||
|
@ -14,7 +14,7 @@ import { evalFunc } from 'sources/utils';
|
|||||||
|
|
||||||
|
|
||||||
export const listenDepChanges = (
|
export const listenDepChanges = (
|
||||||
accessPath, field, visible, schemaState, data, setRefreshKey
|
accessPath, field, schemaState, setRefreshKey
|
||||||
) => {
|
) => {
|
||||||
const deps = field?.deps ? (evalFunc(null, field.deps) || []) : null;
|
const deps = field?.deps ? (evalFunc(null, field.deps) || []) : null;
|
||||||
const parentPath = accessPath ? [...accessPath] : [];
|
const parentPath = accessPath ? [...accessPath] : [];
|
||||||
@ -25,7 +25,7 @@ export const listenDepChanges = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!visible || !schemaState || !field) return;
|
if (!schemaState || !field) return;
|
||||||
|
|
||||||
if(field.depChange || field.deferredDepChange) {
|
if(field.depChange || field.deferredDepChange) {
|
||||||
schemaState.addDepListener(
|
schemaState.addDepListener(
|
||||||
|
@ -188,12 +188,12 @@ export default function MacrosDialog({onClose, onSave}) {
|
|||||||
value: m.id,
|
value: m.id,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const schema = React.useRef(null);
|
||||||
|
|
||||||
if(keyOptions.length <= 0) {
|
if(keyOptions.length <= 0) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const schema = React.useRef(null);
|
|
||||||
|
|
||||||
if (!schema.current)
|
if (!schema.current)
|
||||||
schema.current = new MacrosSchema(keyOptions);
|
schema.current = new MacrosSchema(keyOptions);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user