Skip to content

Commit

Permalink
fix(core/tooltip): styles bleeding in (#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiashader authored Sep 4, 2024
1 parent 7181098 commit 5acd52a
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-carrots-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siemens/ix': patch
---

fix(core/tooltip): styles bleeding in
17 changes: 13 additions & 4 deletions packages/core/src/components/tooltip/tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
overflow-wrap: break-word;

border-radius: 0.25rem;
background-color: var(--theme-tootlip--background);
padding: 0.375rem 0.75rem 0.375rem 0.875rem;

box-shadow: var(--theme-shadow-4);

.tooltip-title {
display: flex;
Expand All @@ -25,6 +21,19 @@
margin-right: 0.35rem;
}
}

.tooltip-container {
display: block;
position: relative;
width: auto;
height: 100%;
background: var(--theme-tootlip--background);
color: var(--theme-color-std-text);
padding: 0.375rem 0.75rem 0.375rem 0.875rem;

box-shadow: var(--theme-shadow-4);

}
}

:host(.visible) {
Expand Down
22 changes: 12 additions & 10 deletions packages/core/src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,19 @@ export class Tooltip implements IxOverlayComponent {
}}
role="tooltip"
>
<div class={'tooltip-title'}>
<slot name="title-icon"></slot>
<ix-typography variant="default-title">
{this.titleContent}
<slot name="title-content"></slot>
</ix-typography>
<div class="tooltip-container">
<div class={'tooltip-title'}>
<slot name="title-icon"></slot>
<ix-typography variant="default-title">
{this.titleContent}
<slot name="title-content"></slot>
</ix-typography>
</div>
<div class={'tooltip-content'}>
<slot></slot>
</div>
<div class="arrow"></div>
</div>
<div class={'tooltip-content'}>
<slot></slot>
</div>
<div class="arrow"></div>
</Host>
);
}
Expand Down
25 changes: 25 additions & 0 deletions packages/core/src/tests/tooltip/overlapping-styles/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@


<!--
SPDX-FileCopyrightText: 2024 Siemens AG
SPDX-License-Identifier: MIT
-->

<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"
/>
<title>Stencil Component Starter</title>
</head>
<body style="padding: 12rem">
<button id="test">Test</button>
<ix-tooltip for="#test" style="background-color: red; width: 25rem; height: 25rem">My tooltip</ix-tooltip>

<script src="http://127.0.0.1:8080/scripts/e2e/load-e2e-runtime.js"></script>
</body>
</html>

11 changes: 11 additions & 0 deletions packages/core/src/tests/tooltip/tooltip.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ regressionTest.describe('tooltip', () => {
});
});

regressionTest('global style not bleeding into tooltip', async ({ page }) => {
await page.goto('tooltip/overlapping-styles');

const tooltipTriggerHandler = await page.waitForSelector('#test');

await tooltipTriggerHandler.hover();
await page.waitForTimeout(500);

expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});

test('tooltip position top', async ({ mount, page }) => {
await mount(`
<div style="padding: 10rem">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5acd52a

Please sign in to comment.