-
-
Notifications
You must be signed in to change notification settings - Fork 287
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 and improve resizing in editor (incl. Add Spacer component) #2818
Changes from 16 commits
1fc9961
87cbb61
e04aff2
340041f
95d16f6
50b9c7d
eb1e0b7
cf7f783
97ec428
4fb61b3
20a5764
62e3ce1
4019fcb
fbfca0b
6f0aaec
1a40eaa
007c311
5e25447
fa07e97
d2c5a8b
0471351
5a40939
44fd577
9cbe298
189a104
0e06cc0
afb84ae
3980eae
af6a74f
7523bb7
9e967de
8608ab4
0efe12b
64ce555
f867615
11caaa3
01f7c34
16db5e6
f05c44b
ffcf428
1ae8a85
1dba2a3
6e1e06c
5fcc01c
19f3ef5
7b9c763
bc14881
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -434,10 +434,8 @@ function getQueryConfigBindings({ enabled, refetchInterval }: appDom.QueryNode[' | |
} | ||
|
||
function isBindableProp(componentConfig: ComponentConfig<any>, propName: string) { | ||
const isResizableHeightProp = propName === componentConfig.resizableHeightProp; | ||
const argType = componentConfig.argTypes?.[propName]; | ||
return ( | ||
!isResizableHeightProp && | ||
argType?.control?.bindable !== false && | ||
argType?.type !== 'template' && | ||
argType?.type !== 'event' | ||
|
@@ -1173,6 +1171,7 @@ function RenderedNodeContent({ node, childNodeGroups, Component }: RenderedNodeC | |
display: 'flex', | ||
alignItems: boundLayoutProps.verticalAlign, | ||
justifyContent: boundLayoutProps.horizontalAlign, | ||
height: node.layout?.height ?? componentConfig.defaultLayoutHeight, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Element heights are controlled in the boxes that wrap components instead of the components themselves. |
||
}} | ||
> | ||
<Component {...wrappedProps} /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -541,6 +541,7 @@ function expandFromDom<N extends appDom.AppDomNode>( | |
name: node.name, | ||
layout: undefinedWhenEmpty({ | ||
columnSize: node.layout?.columnSize, | ||
height: node.layout?.height, | ||
horizontalAlign: stringOnly(node.layout?.horizontalAlign), | ||
verticalAlign: stringOnly(node.layout?.verticalAlign), | ||
}), | ||
|
@@ -732,7 +733,14 @@ function mergePageIntoDom(dom: appDom.AppDom, pageName: string, pageFile: Page): | |
return dom; | ||
} | ||
|
||
function optimizePageElement(element: ElementType): ElementType { | ||
function optimizePageElement( | ||
element: ElementType, | ||
isPageChild = false, | ||
): ElementType | ElementType[] { | ||
if (isPageChild && element.component === PAGE_COLUMN_COMPONENT_ID) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gets rid of page columns inside the page root too, I saw it in a few apps already and it's unnecessary / shouldn't ever happen. |
||
return (element.children || []).flatMap((child) => optimizePageElement(child, true)); | ||
} | ||
|
||
const isLayoutElement = (possibleLayoutElement: ElementType): boolean => | ||
possibleLayoutElement.component === PAGE_ROW_COMPONENT_ID || | ||
possibleLayoutElement.component === PAGE_COLUMN_COMPONENT_ID; | ||
|
@@ -753,7 +761,7 @@ function optimizePageElement(element: ElementType): ElementType { | |
|
||
return { | ||
...element, | ||
children: element.children && element.children.map(optimizePageElement), | ||
children: element.children && element.children.flatMap((child) => optimizePageElement(child)), | ||
}; | ||
} | ||
|
||
|
@@ -762,7 +770,7 @@ function optimizePage(page: Page): Page { | |
...page, | ||
spec: { | ||
...page.spec, | ||
content: page.spec.content?.map(optimizePageElement), | ||
content: page.spec.content?.flatMap((element) => optimizePageElement(element, true)), | ||
}, | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an action in the editor causes a column of elements to be inside the page root, for example, we can spread the contents of the column on the page root directly and get rid of the column element.