Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(layers-visibility) Fixing the layer visiblity parenting #2613

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions packages/geoview-core/src/geo/layer/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1456,10 +1456,6 @@ export class LayerApi {
// Determine the outcome of the new visibility based on parameters
const newVisibility = newValue !== undefined ? newValue : !layerVisibility;
const layerInfos = curOrderedLayerInfo.filter((info: TypeOrderedLayerInfo) => info.layerPath.startsWith(layerPath));
const parentLayerPathArray = layerPath.split('/');
parentLayerPathArray.pop();
const parentLayerPath = parentLayerPathArray.join('/');
const parentLayerInfo = curOrderedLayerInfo.find((info: TypeOrderedLayerInfo) => info.layerPath === parentLayerPath);

layerInfos.forEach((layerInfo: TypeOrderedLayerInfo) => {
if (layerInfo) {
Expand All @@ -1475,7 +1471,12 @@ export class LayerApi {
}
});

if (parentLayerInfo !== undefined) {
// For each parent
const parentLayerPathArray = layerPath.split('/');
parentLayerPathArray.pop();
let parentLayerPath = parentLayerPathArray.join('/');
let parentLayerInfo = curOrderedLayerInfo.find((info: TypeOrderedLayerInfo) => info.layerPath === parentLayerPath);
while (parentLayerInfo !== undefined) {
const parentLayerVisibility = MapEventProcessor.getMapVisibilityFromOrderedLayerInfo(this.getMapId(), parentLayerPath);
if ((!layerVisibility || newValue) && parentLayerVisibility === false) {
if (parentLayerInfo) {
Expand All @@ -1487,6 +1488,7 @@ export class LayerApi {
}
}
const children = curOrderedLayerInfo.filter(
// eslint-disable-next-line no-loop-func
(info: TypeOrderedLayerInfo) => info.layerPath.startsWith(parentLayerPath) && info.layerPath !== parentLayerPath
);
if (!children.some((child: TypeOrderedLayerInfo) => child.visible === true)) {
Expand All @@ -1495,6 +1497,12 @@ export class LayerApi {
// Emit event
this.#emitLayerVisibilityToggled({ layerPath, visibility: false });
}

// Prepare for next parent
parentLayerPathArray.pop();
parentLayerPath = parentLayerPathArray.join('/');
// eslint-disable-next-line no-loop-func
parentLayerInfo = curOrderedLayerInfo.find((info: TypeOrderedLayerInfo) => info.layerPath === parentLayerPath);
}

// Redirect to processor so we can update the store with setterActions
Expand Down
Loading