Skip to content

Commit

Permalink
chore: display position section for root element if position is set o…
Browse files Browse the repository at this point in the history
…ther than auto

GitOrigin-RevId: 688989ab90c6335ee94c32117a55128d596fee24
  • Loading branch information
abbas-nazar authored and actions-user committed Dec 26, 2024
1 parent 3607867 commit 365d4b7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ import {
import { ValComponent } from "@/wab/shared/core/val-nodes";
import { DEVFLAGS, DevFlagsType } from "@/wab/shared/devflags";
import { isGridTag } from "@/wab/shared/grid-utils";
import { isPositionSet } from "@/wab/shared/layoututils";
import {
TplComponent,
TplNode,
Expand Down Expand Up @@ -569,7 +570,7 @@ export function getRenderBySection(
Section.PositioningPanel,
() =>
(isTag || isComponent) &&
!isRoot &&
(!isRoot || isPositionSet(tpl, viewCtx)) &&
!isColumn &&
!isTplTextBlock(tpl.parent) &&
showSection(Section.PositioningPanel) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ import {
import {
computeDefinedIndicator,
DefinedIndicatorType,
isIndicatorExplicitlySet,
getPropAndValueFromIndicator,
isIndicatorExplicitlySet,
} from "@/wab/shared/defined-indicator";
import { makeExpProxy, makeMergedExpProxy } from "@/wab/shared/exprs";
import {
Expand All @@ -78,6 +78,7 @@ import {
ContainerType,
convertSelfContainerType,
getRshContainerType,
isPositionSet,
PositionLayoutType,
} from "@/wab/shared/layoututils";
import {
Expand Down Expand Up @@ -1304,7 +1305,7 @@ export class TplExpsProvider implements ExpsProvider {

showPositioningPanel = () => {
// Don't show positioning panel for the root node
return !!this.tpl.parent;
return !!this.tpl.parent || isPositionSet(this.tpl, this.viewCtx);
};

getTargetDeepLayoutParentRsh = () => {
Expand Down
42 changes: 29 additions & 13 deletions platform/wab/src/wab/shared/layoututils.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
import { unexpected } from "@/wab/shared/common";
import type { ViewCtx } from "@/wab/client/studio-ctx/view-ctx";
import { isMixinPropRef, isTokenRef } from "@/wab/commons/StyleToken";
import { DeepReadonly } from "@/wab/commons/types";
import { parseCssNumericNew } from "@/wab/shared/css";
import { createGridSpec, showGridCss } from "@/wab/shared/Grids";
import { HORIZ_CONTAINER_CAP, VERT_CONTAINER_CAP } from "@/wab/shared/Labels";
import {
IRuleSetHelpers,
IRuleSetHelpersX,
RSH,
ReadonlyIRuleSetHelpers,
ReadonlyIRuleSetHelpersX,
} from "@/wab/shared/RuleSetHelpers";
import { ensureBaseVariantSetting } from "@/wab/shared/Variants";
import { unexpected } from "@/wab/shared/common";
import {
CONTENT_LAYOUT,
FAKE_FLEX_CONTAINER_PROPS,
GAP_PROPS,
contentLayoutProps,
gridCssProps,
} from "@/wab/shared/core/style-props";
import {
getTplTagRoot,
isTplComponent,
isTplVariantable,
} from "@/wab/shared/core/tpls";
import { parseCssNumericNew } from "@/wab/shared/css";
import { CONTENT_LAYOUT_INITIALS } from "@/wab/shared/default-styles";
import { createGridSpec, showGridCss } from "@/wab/shared/Grids";
import { HORIZ_CONTAINER_CAP, VERT_CONTAINER_CAP } from "@/wab/shared/Labels";
import {
RuleSet,
TplNode,
TplTag,
VariantSetting,
} from "@/wab/shared/model/classes";
import { getTplTagRoot, isTplComponent, isTplVariantable } from "@/wab/shared/core/tpls";
import {
IRuleSetHelpers,
IRuleSetHelpersX,
RSH,
ReadonlyIRuleSetHelpers,
ReadonlyIRuleSetHelpersX,
} from "@/wab/shared/RuleSetHelpers";
import { ensureBaseVariantSetting } from "@/wab/shared/Variants";

export type ContainerType =
| "free"
Expand Down Expand Up @@ -345,3 +350,14 @@ export function isContentLayoutTpl(tpl: TplNode, opts?: { deep?: boolean }) {
}
return false;
}

export function isPositionSet(tpl: TplNode, viewCtx: ViewCtx) {
// Check if the position is available and set to something other than "auto".
const vtm = viewCtx.variantTplMgr();
const targetVariantCombo = vtm.getTargetVariantComboForNode(tpl);
const effectiveExp = vtm
.effectiveVariantSetting(tpl, targetVariantCombo)
.rsh();
const curPosType = getRshPositionType(effectiveExp);
return curPosType && curPosType !== PositionLayoutType.auto;
}

0 comments on commit 365d4b7

Please sign in to comment.