Skip to content

chore: added story to demonstrate a delayed tooltip example #5384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-terms-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@spectrum-web-components/tooltip': patch
---

docs: add DelayedTooltipWithOverlay story demonstrating how to handle interactions between delayed tooltips and other overlay components
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ parameters:
# 3. Commit this change to the PR branch where the changes exist.
current_golden_images_hash:
type: string
default: 3412e93be28e587e2ded76d6c19d051e401e2623
default: b7ea01b7daaccc2c345f09b26beb38c0a3791f8b
wireit_cache_name:
type: string
default: wireit
101 changes: 101 additions & 0 deletions packages/tooltip/stories/tooltip.stories.ts
Original file line number Diff line number Diff line change
@@ -22,6 +22,10 @@ import '@spectrum-web-components/textfield/sp-textfield.js';
import '@spectrum-web-components/action-button/sp-action-button.js';
import { Placement } from '@spectrum-web-components/overlay';
import '@spectrum-web-components/overlay/sp-overlay.js';
import '@spectrum-web-components/popover/sp-popover.js';
import '@spectrum-web-components/overlay/overlay-trigger.js';
// Import Overlay type for type casting
import type { Overlay } from '@spectrum-web-components/overlay';

const iconOptions: {
[key: string]: ({
@@ -454,3 +458,100 @@ draggable.parameters = {
// Disables Chromatic's snapshotting on a global level
chromatic: { disableSnapshot: true },
};

export const DelayedTooltipWithOverlay = (): TemplateResult => {
return html`
<div
style="width: 100%; max-width: 800px; margin: 0 auto; padding: 20px;"
>
<h2>Delayed Tooltip Overlay Interaction Issue</h2>
<div style="display: flex; gap: 24px; margin-bottom: 24px;">
<!-- First overlay - this should stay open during tooltip warmup -->
<sp-button variant="primary" id="button1">
Click to Open Popover
</sp-button>
<sp-overlay
trigger="button1@click"
placement="bottom"
id="popover-overlay"
>
<sp-popover>
<div style="padding: 20px;">
<h3 style="margin-top: 0;">Opened Popover</h3>
<p>
This popover should stay open during tooltip
warmup
</p>
<p>
<strong>Steps to test:</strong>
With this popover open, hover the button to the
right.
</p>
</div>
</sp-popover>
</sp-overlay>
<overlay-trigger triggered-by="hover">
<sp-button
slot="trigger"
variant="secondary"
@pointerenter=${(event: Event) => {
// Capture phase event handler to stop propagation during warmup
// This ensures other overlays don't close prematurely
event.stopPropagation();
}}
>
Hover me
</sp-button>
<sp-tooltip
slot="hover-content"
delayed
placement="bottom"
@sp-opened=${() => {
const popoverOverlay = document.getElementById(
'popover-overlay'
) as Overlay;
if (
popoverOverlay &&
popoverOverlay.hasAttribute('open')
) {
popoverOverlay.open = false;
}
}}
>
This is a delayed tooltip
</sp-tooltip>
</overlay-trigger>
</div>
<div
style="border: 1px solid #ccc; padding: 20px; border-radius: 4px; background-color: #f5f5f5;"
>
<h3 style="margin-top: 0;">Expected Behavior</h3>
<ol style="margin-left: 16px;">
<li>
Click the
<strong>Click to Open Popover</strong>
button to open the popover
</li>
<li>
Hover over the
<strong>Hover me</strong>
button
</li>
<li>
The popover should
<strong>remain open</strong>
during the tooltip's 1-second warmup period
</li>
<li>
The popover should
<strong>automatically close</strong>
when the tooltip appears in DOM
</li>
</ol>
</div>
</div>
`;
};