Commit e7b11351 authored by jan.koester's avatar jan.koester
Browse files

grid scretch bugfix

parent 346871ab
Loading
Loading
Loading
Loading
+23 −0
Changes for editor/widgets/grid/grid.cpp: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -692,10 +692,33 @@ extern "C" {
                }

                // Render children into grid cells
                //
                // align-items:stretch on the grid only stretches this wrapper
                // cell div to the row height — it does not cascade into the
                // widget rendered inside the cell, which just sizes to its own
                // content, leaving the "stretch" vertical-align option with no
                // visible effect. When stretch is requested, turn the cell
                // into a flex column and grow its one child to fill it.
                std::string cellClass = "we-cell-" + getInstanceId();
                std::string stretchCSS;
                if (verticalAlign == "stretch") {
                    stretchCSS += "." + cellClass + " { display: flex; flex-direction: column; }";
                    stretchCSS += " ." + cellClass + " > * { flex: 1 1 auto; min-height: 0; }";
                }
                if (m_verticalAlign == "stretch") {
                    stretchCSS += " @media (max-width: 768px) { ." + cellClass + " { display: flex !important; flex-direction: column !important; } ." + cellClass + " > * { flex: 1 1 auto !important; min-height: 0 !important; } }";
                }
                if (!stretchCSS.empty()) {
                    libhtmlpp::HtmlElement stretchStyleTag("style");
                    stretchStyleTag.appendChild(libhtmlpp::TextElement(stretchCSS.c_str()));
                    el.appendChild(stretchStyleTag);
                }

                const EditPlugin *cur = child;
                while (cur) {
                    libhtmlpp::HtmlElement cell("div");
                    cell.setAttribute("style", "min-width: 0; box-sizing: border-box;");
                    cell.setAttribute("class", cellClass.c_str());
                    cur->Render(cell);
                    grid.appendChild(cell);
                    cur = cur->nextElement();