From fc8e744dd93d36782996aed12efa776f6eb1a899 Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Mon, 2 Dec 2024 12:20:12 +0200 Subject: [PATCH] refactor!: set white-space: pre-wrap on the tooltip content (#8255) --- packages/tooltip/src/vaadin-tooltip-overlay-styles.js | 4 ++++ packages/tooltip/test/visual/lumo/tooltip.test.js | 3 --- packages/tooltip/test/visual/material/tooltip.test.js | 3 --- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/tooltip/src/vaadin-tooltip-overlay-styles.js b/packages/tooltip/src/vaadin-tooltip-overlay-styles.js index eacd426951..5d8d28ded4 100644 --- a/packages/tooltip/src/vaadin-tooltip-overlay-styles.js +++ b/packages/tooltip/src/vaadin-tooltip-overlay-styles.js @@ -10,6 +10,10 @@ export const tooltipOverlayStyles = css` max-width: 40ch; } + [part='content'] { + white-space: pre-wrap; + } + :host([position^='top'][top-aligned]) [part='overlay'], :host([position^='bottom'][top-aligned]) [part='overlay'] { margin-top: var(--vaadin-tooltip-offset-top, 0); diff --git a/packages/tooltip/test/visual/lumo/tooltip.test.js b/packages/tooltip/test/visual/lumo/tooltip.test.js index 6be9460665..cb396ae554 100644 --- a/packages/tooltip/test/visual/lumo/tooltip.test.js +++ b/packages/tooltip/test/visual/lumo/tooltip.test.js @@ -70,9 +70,6 @@ describe('tooltip', () => { it('white-space-pre', async () => { element.text = 'Line 1\n\nLine 2'; fire(target, 'mouseenter'); - const overlay = document.querySelector('vaadin-tooltip-overlay'); - const content = overlay.shadowRoot.querySelector('[part="content"]'); - content.style.whiteSpace = 'pre'; await visualDiff(div, 'white-space-pre'); }); }); diff --git a/packages/tooltip/test/visual/material/tooltip.test.js b/packages/tooltip/test/visual/material/tooltip.test.js index 2434e4a763..697a715671 100644 --- a/packages/tooltip/test/visual/material/tooltip.test.js +++ b/packages/tooltip/test/visual/material/tooltip.test.js @@ -73,9 +73,6 @@ describe('tooltip', () => { it('white-space-pre', async () => { element.text = 'Line 1\n\nLine 2'; fire(target, 'mouseenter'); - const overlay = document.querySelector('vaadin-tooltip-overlay'); - const content = overlay.shadowRoot.querySelector('[part="content"]'); - content.style.whiteSpace = 'pre'; await visualDiff(div, 'white-space-pre'); }); });