Skip to content

#12951 False save button activation happens on map first load - #12952

Merged
dsuren1 merged 5 commits into
geosolutions-it:masterfrom
Binabh:fix/false-save-as
Oct 8, 2026
Merged

dsuren1 merged 5 commits into
geosolutions-it:masterfrom
Binabh:fix/false-save-as

Conversation

@Binabh

@Binabh Binabh commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Description

Change comparison logic to add includes rules and check map comparison based on includes fields.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix

Issue

What is the current behavior?

#12951

What is the new behavior?
Unsaved state is not falsely triggered

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • No

@Binabh Binabh added this to the 2026.02.02 milestone Oct 6, 2026
@Binabh
Binabh requested a review from allyoucanmap October 6, 2026 15:12
@Binabh Binabh linked an issue Oct 6, 2026 that may be closed by this pull request
1 task done
@Binabh Binabh added the bug label Oct 6, 2026
@cla-bot cla-bot Bot added the CLA Ready label Oct 6, 2026
@tdipisa tdipisa modified the milestones: 2026.02.02, 2026.02.03 Oct 7, 2026
@tdipisa
tdipisa requested review from dsuren1 and removed request for allyoucanmap October 7, 2026 10:00
@tdipisa tdipisa assigned dsuren1 and unassigned allyoucanmap Oct 7, 2026

@dsuren1 dsuren1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Binabh
The approach of adding includes creates some friction and adds maintenance overhead, especially since it introduces a second list of layer properties that needs to stay in sync with saveLayer.
Would it be possible to reuse the existing saveLayer/formatting logic for the comparison instead? This would give us a single source of truth and also avoid potential differences such as the WMTS matrixIds/tileMatrixSet transformations.

Please check my suggested approach, I haven't completely tested it, and see if it handles all the cases. Thanks!

Comment thread web/client/utils/MapUtils.js Outdated
Comment on lines +1188 to +1267
const includes = {
// Compare the layer configuration fields persisted by saveLayer in LayersUtils.
'root.map.layers[]': [
'id',
'features',
'format',
'thumbURL',
'group',
'search',
'fields',
'source',
'name',
'opacity',
'provider',
'description',
'styles',
'style',
'styleName',
'layerFilter',
'title',
'transparent',
'tiled',
'type',
'url',
'bbox',
'visibility',
'singleTile',
'allowedSRS',
'requestEncoding',
'dimensions',
'maxZoom',
'maxNativeZoom',
'maxResolution',
'minResolution',
'disableResolutionLimits',
'hideLoading',
'handleClickOnLayer',
'queryable',
'featureInfo',
'catalogURL',
'capabilitiesURL',
'serverType',
'useForElevation',
'hidden',
'origin',
'thematic',
'tooltipOptions',
'tooltipPlacement',
'legendOptions',
'tileSize',
'version',
'expanded',
'enableInteractiveLegend',
'enableDynamicLegend',
'sources',
'heightOffset',
'params',
'extendedParams',
'localizedLayerStyles',
'options',
'credits',
'security',
'tileGrids',
'tileGridStrategy',
'tileGridCacheSupport',
'rowViewer',
'forceProxy',
'disableFeaturesEditing',
'pointCloudShading',
'sourceMetadata',
'enableImageryOverlay',
'strategy',
'geometryType',
'maxRecordCount',
'maxFeaturesInView',
'cropToProjectionExtent',
'coalesce'
]
};
const excludes = {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const includes = {
// Compare the layer configuration fields persisted by saveLayer in LayersUtils.
'root.map.layers[]': [
'id',
'features',
'format',
'thumbURL',
'group',
'search',
'fields',
'source',
'name',
'opacity',
'provider',
'description',
'styles',
'style',
'styleName',
'layerFilter',
'title',
'transparent',
'tiled',
'type',
'url',
'bbox',
'visibility',
'singleTile',
'allowedSRS',
'requestEncoding',
'dimensions',
'maxZoom',
'maxNativeZoom',
'maxResolution',
'minResolution',
'disableResolutionLimits',
'hideLoading',
'handleClickOnLayer',
'queryable',
'featureInfo',
'catalogURL',
'capabilitiesURL',
'serverType',
'useForElevation',
'hidden',
'origin',
'thematic',
'tooltipOptions',
'tooltipPlacement',
'legendOptions',
'tileSize',
'version',
'expanded',
'enableInteractiveLegend',
'enableDynamicLegend',
'sources',
'heightOffset',
'params',
'extendedParams',
'localizedLayerStyles',
'options',
'credits',
'security',
'tileGrids',
'tileGridStrategy',
'tileGridCacheSupport',
'rowViewer',
'forceProxy',
'disableFeaturesEditing',
'pointCloudShading',
'sourceMetadata',
'enableImageryOverlay',
'strategy',
'geometryType',
'maxRecordCount',
'maxFeaturesInView',
'cropToProjectionExtent',
'coalesce'
]
};
const excludes = {};
const excludes = {
'root.map.layers[]': ['apiKey', 'time', 'args', 'fixed']
};

Comment thread web/client/utils/MapUtils.js Outdated
@@ -1199,7 +1280,7 @@ export const compareMapChanges = (map1 = {}, map2 = {}) => {
return (value || []).filter(layer => !(layer.type === 'terrain' && layer.provider === 'ellipsoid'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return (value || []).filter(layer => !(layer.type === 'terrain' && layer.provider === 'ellipsoid'));
const layers = (value || [])
.filter(layer => !(layer.type === 'terrain' && layer.provider === 'ellipsoid'))
.map(saveLayer);
return formatLayersForSave(layers).formattedLayers;

Comment thread web/client/utils/MapUtils.js Outdated
}
};
const isSame = !recursiveIsChangedWithRules(map1, map2, { pickedFields, aliases, excludes, parsers }, 'root');
const isSame = !recursiveIsChangedWithRules(map1, map2, { pickedFields, aliases, includes, excludes, parsers }, 'root');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isSame = !recursiveIsChangedWithRules(map1, map2, { pickedFields, aliases, includes, excludes, parsers }, 'root');
const isSame = !recursiveIsChangedWithRules(map1, map2, { pickedFields, aliases, excludes, parsers }, 'root');

Comment thread web/client/utils/MapUtils.js Outdated
Comment on lines 820 to 870

@dsuren1 dsuren1 Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a function of this logic as formatLayersForSave that returns { formattedLayers, sources } and reuse it

Comment thread web/client/utils/MapUtils.js Outdated
Comment on lines +1076 to +1078
if (includes[parentPath]?.length && !includes[parentPath].includes(key)) {
return false;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (includes[parentPath]?.length && !includes[parentPath].includes(key)) {
return false;
}

Comment thread web/client/utils/MapUtils.js Outdated
* @returns {boolean} True if the field should be included, false otherwise.
*/
export const filterFieldByRules = (path, key, value, { pickedFields = [], excludes = {} }) => {
export const filterFieldByRules = (path, key, value, { pickedFields = [], includes = {}, excludes = {} }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const filterFieldByRules = (path, key, value, { pickedFields = [], includes = {}, excludes = {} }) => {
export const filterFieldByRules = (path, key, value, { pickedFields = [], excludes = {} }) => {

@Binabh
Binabh requested a review from dsuren1 October 8, 2026 10:40
Comment thread web/client/utils/MapUtils.js Outdated
export const compareMapChanges = (map1 = {}, map2 = {}) => {
const pickedFields = [
'root.map.layers',
'root.map.sources',

@dsuren1 dsuren1 Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Binabh Could you please check if source can be avoided. As @allyoucanmap suggested this could be compute expensive.

@Binabh
Binabh requested a review from dsuren1 October 8, 2026 11:55
@Binabh

Binabh commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

@dsuren1 Yes that could be removed. I have verified also. Also I have re-requested your review. Thank You!

@dsuren1
dsuren1 enabled auto-merge (squash) October 8, 2026 11:59
@dsuren1

dsuren1 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@Binabh Some tests are failing. Kindly address it. Thanks!

@dsuren1
dsuren1 merged commit be4973f into geosolutions-it:master Oct 8, 2026
11 checks passed
@dsuren1

dsuren1 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@ElenaGallo Kindly test it in DEV. Thanks!

@landryb

landryb commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

fwiw i can confirm that (when backported on 2025.02), in my limited testing it fixes georchestra/mapstore2-georchestra#816 for me. much appreciated.

@offtherailz

Copy link
Copy Markdown
Member

Request failed due to following response errors:

  • Pull request Pull request is a draft

@offtherailz

Copy link
Copy Markdown
Member

Request failed due to following response errors:

  • Pull request Pull request is a draft

@offtherailz

Copy link
Copy Markdown
Member

Request failed due to following response errors:

  • Pull request Pull request is a draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False save button activation happens on map first load

6 participants