Skip to content

Commit

Permalink
Fix #9575 Avoid full rerender in filterRenderer (#9577) (#9582)
Browse files Browse the repository at this point in the history
* Fix #9575 Avoid full rerender in filterRenderer

* Fixed wrong usage of usememo

* Update web/client/plugins/featuregrid/__tests__/FeatureEditor-test.jsx

* Update web/client/plugins/featuregrid/FeatureEditor.jsx

* Update FeatureEditor.jsx
  • Loading branch information
offtherailz authored Oct 12, 2023
1 parent 1d95e60 commit b81c200
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions web/client/selectors/__tests__/featuregrid-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,20 @@ describe('Test featuregrid selectors', () => {
}
};
expect(selectedLayerFieldsSelector(state)).toEqual([FIELD]);
// check that fields are memoized when applying defaults
const stateEmptyFields = {
featuregrid: {
selectedLayer: 'TEST_LAYER'
},
layers: {
flat: [{
id: "TEST_LAYER",
title: "Test Layer",
name: 'editing:polygons.test'
}]
}
};
expect(selectedLayerFieldsSelector(stateEmptyFields)).toBe(selectedLayerFieldsSelector(stateEmptyFields));
});
it('editingAllowedGroupsSelector', () => {
const editingAllowedGroups = ['test'];
Expand Down
4 changes: 2 additions & 2 deletions web/client/selectors/featuregrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ export const getTitleSelector = state => {
const title = getTitle(getLayerById(state, selectedLayerIdSelector(state)));
return isObject(title) ? title[currentLocaleSelector(state)] || title.default || '' : title;
};

const STANDARD_FIELDS = [];
/**
* Returns the current selected layer (featuregrid) fields, if any.
* @param {*} state
* @returns {object} the current selected layer fields, if any
*/
export const selectedLayerFieldsSelector = state => {
const layer = getLayerById(state, selectedLayerIdSelector(state));
const fields = get(layer, "fields", []);
const fields = get(layer, "fields", STANDARD_FIELDS);
return fields;
};
export const getCustomizedAttributes = state => {
Expand Down

0 comments on commit b81c200

Please sign in to comment.