mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-09 22:14:29 +09:00
fix: show flex child for collection item (#4467)
Fixes https://github.com/webstudio-is/webstudio/issues/4458 Collection is not stylable and was checked for display: flex but instead should be skipped.
This commit is contained in:
1 parent
fd2bc2607d
commit
b8b489c93c
1 file changed
+28
-2
@@ -318,15 +318,41 @@ export const useComputedStyleDecl = (property: StyleProperty) => {
|
||||
return useStore($store);
|
||||
};
|
||||
|
||||
const $closestStylableInstanceSelector = computed(
|
||||
[$instanceAndRootSelector, $instances, $registeredComponentMetas],
|
||||
(instanceSelector, instances, metas) => {
|
||||
// ignore unstylable instances which do not affect parent/child relationships
|
||||
if (instanceSelector === undefined) {
|
||||
return;
|
||||
}
|
||||
const closestStylableIndex = instanceSelector.findIndex(
|
||||
(instanceId, index) => {
|
||||
// start with parent
|
||||
if (index === 0) {
|
||||
return false;
|
||||
}
|
||||
const component = instances.get(instanceId)?.component;
|
||||
if (component) {
|
||||
return metas.get(component)?.stylable ?? true;
|
||||
}
|
||||
// ids without instances are collection items
|
||||
// they are not stylable
|
||||
return false;
|
||||
}
|
||||
);
|
||||
return instanceSelector.slice(closestStylableIndex);
|
||||
}
|
||||
);
|
||||
|
||||
export const useParentComputedStyleDecl = (property: StyleProperty) => {
|
||||
const $store = useMemo(
|
||||
() =>
|
||||
computed(
|
||||
[$model, $instanceAndRootSelector],
|
||||
[$model, $closestStylableInstanceSelector],
|
||||
(model, instanceSelector) => {
|
||||
return getComputedStyleDecl({
|
||||
model,
|
||||
instanceSelector: instanceSelector?.slice(1),
|
||||
instanceSelector,
|
||||
property,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user