# Dialog Style Guide All new dialogs using `CustomDialog` should follow these patterns for consistent appearance. CSS classes are defined in `/src/main/webapp/styles/grapheditor.css`. ## Auto-Height Pass `null` for the height parameter in `showDialog()`. The `Dialog` constructor measures `elt.scrollHeight` after the element is in the DOM and sizes the dialog automatically. Never compute dialog heights manually with `height += N` increments. ```javascript var dlg = new CustomDialog(this, div, okFn, null, mxResources.get('export'), helpLink); this.showDialog(dlg.container, 360, null, true, true); ``` ## Viewport Overflow `.geDialog` is capped at viewport height by `max-height: 100%`. When the natural dialog height exceeds the viewport (small screens, expanded sections), the content area becomes scrollable so the footer stays reachable: - **CustomDialog**: the wrapper is a flex column. Content sits in a scrollable middle region (`flex: 1 1 auto; min-height: 0; overflow-y: auto`). The button row is `flex: 0 0 auto` and stays pinned at the bottom. - **Other dialogs**: a CSS safety net (`.geDialog > :first-child`) applies `max-height: 100%; overflow-y: auto` so the content scrolls if it overflows — buttons inside scroll with the content but remain reachable. - **Close button (`.geButton`)**: positioned-absolute sibling of the content, so it stays at the top-right regardless of scroll. ## Spacing (handled by CustomDialog and Dialog) - **Dialog padding**: 24px on all sides (`.geDialog` CSS) - **Title margin-bottom**: 16px (`.geDialog h3` CSS) - **Buttons margin-top**: 34px (default in `CustomDialog`) - **Container padding-bottom**: 10px (`CustomDialog` adds this to prevent margin collapse) - **Dialog chrome**: `Dialog` constructor adds 48px to both width and height for padding These produce equal visual spacing above (34px) and below (34px = 10px + 24px) the button row. Do not override these values in individual dialogs. ## Sections (`geDialogSection`) Group related controls in rounded section containers: ```javascript var section = document.createElement('div'); section.className = 'geDialogSection'; // ... add rows to section ... div.appendChild(section); ``` **Row spacing is uniform and CSS-driven.** Every row inside a section (`geDialogFormRow`, `geDialogCheckRow`, `geDialogInlineFields`) is spaced a uniform `6px` from the previous one; the first visible row sits flush against the section's 10px top padding. This is handled centrally in `grapheditor.css` — do **not** add per-row `margin-top` (it only breaks the uniform rhythm). Because the gap is between rows regardless of type, a section can freely mix form rows, check rows and inline fields and they stay evenly spaced. For the same reason, always wrap controls in a proper row class (or use `addCheckbox(..., useCheckRow=true)`): row classes carry `min-height: 28px`, so mixing a bare `addCheckbox` (no `useCheckRow`, which appends a raw `