Skip to content

Commit

Permalink
♻️ Trigger useStory via useLayout by changing LayerName when grou…
Browse files Browse the repository at this point in the history
…p is undefined
  • Loading branch information
AnuragVasanwala committed Nov 15, 2023
1 parent a3c73c2 commit 8ddc6bd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
16 changes: 15 additions & 1 deletion packages/story-editor/src/components/panels/layer/groupLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,21 @@ function GroupLayer({ groupId }) {
})
);

const { name, isLocked, isCollapsed } = groups[groupId];
const DEFAULT_NAME = 'Undefined Layer';
const DEFAULT_IS_LOCKED = false;
const DEFAULT_IS_COLLAPSED = false;

Check warning on line 83 in packages/story-editor/src/components/panels/layer/groupLayer.js

View check run for this annotation

Codecov / codecov/patch

packages/story-editor/src/components/panels/layer/groupLayer.js#L81-L83

Added lines #L81 - L83 were not covered by tests

// Destructuring with default values in case groups[groupId] is undefined
let {
name = DEFAULT_NAME,
isLocked = DEFAULT_IS_LOCKED,
isCollapsed = DEFAULT_IS_COLLAPSED,
} = {};

Check warning on line 90 in packages/story-editor/src/components/panels/layer/groupLayer.js

View check run for this annotation

Codecov / codecov/patch

packages/story-editor/src/components/panels/layer/groupLayer.js#L90

Added line #L90 was not covered by tests

// Check if groups and groups[groupId] exist before destructuring
if (groups && groups[groupId]) {
({ name, isLocked, isCollapsed } = groups[groupId]);

Check warning on line 94 in packages/story-editor/src/components/panels/layer/groupLayer.js

View check run for this annotation

Codecov / codecov/patch

packages/story-editor/src/components/panels/layer/groupLayer.js#L93-L94

Added lines #L93 - L94 were not covered by tests
}

const { isSelected, handleClick } = useGroupSelection(groupId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,20 @@ function GroupLayerActions({ groupId }) {
),
}));

const group = groups[groupId];
const DEFAULT_NAME = 'Undefined Layer';
const DEFAULT_IS_LOCKED = false;
const DEFAULT_IS_COLLAPSED = false;

Check warning on line 54 in packages/story-editor/src/components/panels/layer/groupLayerActions.js

View check run for this annotation

Codecov / codecov/patch

packages/story-editor/src/components/panels/layer/groupLayerActions.js#L52-L54

Added lines #L52 - L54 were not covered by tests

let group = {

Check warning on line 56 in packages/story-editor/src/components/panels/layer/groupLayerActions.js

View check run for this annotation

Codecov / codecov/patch

packages/story-editor/src/components/panels/layer/groupLayerActions.js#L56

Added line #L56 was not covered by tests
name: DEFAULT_NAME,
isLocked: DEFAULT_IS_LOCKED,
isCollapsed: DEFAULT_IS_COLLAPSED,
};

if (groups && groups[groupId]) {
group = groups[groupId];

Check warning on line 63 in packages/story-editor/src/components/panels/layer/groupLayerActions.js

View check run for this annotation

Codecov / codecov/patch

packages/story-editor/src/components/panels/layer/groupLayerActions.js#L62-L63

Added lines #L62 - L63 were not covered by tests
}

const allLayersHidden = groupLayers.every((layer) => layer.isHidden);

const visibilityTitle = allLayersHidden
Expand Down

0 comments on commit 8ddc6bd

Please sign in to comment.