From 5f2b51fe02cacf4ae567c69d34621414182a5924 Mon Sep 17 00:00:00 2001
From: Marta Bondyra <4283304+mbondyra@users.noreply.github.com>
Date: Tue, 28 Oct 2025 14:46:01 +0100
Subject: [PATCH] [Markdown] Fix layout issues for markdown embeddables in
small panels (#240806)
## Summary
Fixes layout issues for markdown embeddables in small dashboard panels
using CSS container queries. When a markdown panel is shorter than
120px, the UI now adapts to a compact layout that maximizes usable
space.
## Problem
Markdown embeddables are not rendering correctly in small (short)
panels. The editor toolbar and footer would take up significant vertical
space, leaving little room for content editing in constrained layouts.
Turns out that this usecase can be more important to just ignore it,
since users might use small panels to only place the title in the
dashboard.
## Solution
### Layout Improvements
Implemented responsive layout using CSS container queries (@container)
to detect when panels are too small and automatically switch to a
compact layout:
When container height < 120px:
- Editor toolbar is hidden to maximize editing space - toolbar can be
useful but it's not essential for the users to edit their markdown
panels.
- Footer transforms to compact overlay positioned in the top-right
corner with transparent background
The new layout
The smallest layout that still follows the 'classic' design
(cherry picked from commit ec67b3d637f5f3dec965b0bc29bb673cf999cbfa)
---
.../public/components/markdown_editor.tsx | 18 +++++++++++++---
.../public/components/markdown_footer.tsx | 21 +++++++++++++++----
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/src/platform/plugins/shared/dashboard_markdown/public/components/markdown_editor.tsx b/src/platform/plugins/shared/dashboard_markdown/public/components/markdown_editor.tsx
index b4a033d5fef8a..c5465a59dfc04 100644
--- a/src/platform/plugins/shared/dashboard_markdown/public/components/markdown_editor.tsx
+++ b/src/platform/plugins/shared/dashboard_markdown/public/components/markdown_editor.tsx
@@ -15,7 +15,7 @@ import type { PublishingSubject } from '@kbn/presentation-publishing';
import { useStateFromPublishingSubject } from '@kbn/presentation-publishing';
import React, { useLayoutEffect, useRef } from 'react';
import { useMemoCss } from '@kbn/css-utils/public/use_memo_css';
-import { FOOTER_HELP_TEXT, MarkdownFooter } from './markdown_footer';
+import { SHORT_CONTAINER_QUERY, FOOTER_HELP_TEXT, MarkdownFooter } from './markdown_footer';
import { MarkdownRenderer } from './markdown_renderer';
interface EuiMarkdownEditorRef {
@@ -24,6 +24,11 @@ interface EuiMarkdownEditorRef {
}
const componentStyles = {
+ rootContainer: css({
+ display: 'flex',
+ width: '100%',
+ containerType: 'size',
+ }),
container: css({
width: '100%',
}),
@@ -43,6 +48,13 @@ const componentStyles = {
textarea: {
minBlockSize: 'initial',
},
+ [SHORT_CONTAINER_QUERY]: {
+ blockSize: `100%`,
+ // TODO: Do not use data-test-subj to style - should be fixed in EUI
+ '[data-test-subj="euiMarkdownEditorToolbar"]': {
+ display: 'none',
+ },
+ },
}),
};
@@ -82,7 +94,7 @@ export const MarkdownEditor = ({
const isSaveable = Boolean(value === '' || value !== content);
return (
- <>
+