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: Incorrect rendering of Grid element in editor #2007

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { CSSProperties } from "react";
import kebabCase from "lodash/kebabCase";
import styled from "@emotion/styled";
import { css } from "emotion";
import { PbEditorElement, DisplayMode } from "../../../../types";
import Element from "../../../components/Element";
import { PbEditorElement, DisplayMode } from "~/types";
import Element from "~/editor/components/Element";

const StyledGrid = styled("div")({
display: "flex",
Expand Down Expand Up @@ -32,16 +32,26 @@ const Grid: React.FunctionComponent<GridPropsType> = ({
const containerStyle = elementStyle || {};
// Use per-device style
const alignItems = elementStyle[`--${kebabCase(displayMode)}-align-items`];
const gridStyles = {
alignItems,
/**
* The "max-width" property is being assigned to "Grid" element from grid's width setting value,
* which works fine for the page preview and website application.
* But, not in page editor, because, inside page editor the wrapper component is responsible
* for setting up the "width" due to current design choices.
* So, here we're overriding this property value so that it'll look identical to website and
* don't confuse the user.
*/
maxWidth: "100%"
};
return (
<StyledGrid
className={combineClassNames(
...customClasses,
"webiny-pb-layout-grid-container " + css(containerStyle as any)
)}
{...elementAttributes}
style={{
alignItems
}}
style={gridStyles}
>
{element.elements.map((child: PbEditorElement) => {
return (
Expand Down