Skip to content

Commit 700489f

Browse files
RajdeepcRajdeep Chandra
and
Rajdeep Chandra
authored
chore: added story to demonstrate a delayed tooltip example (#5384)
* chore: added story to demonstrate a delayed tooltip example * chore: added changeset * ci: updated golden image cache * ci: update golden image cache --------- Co-authored-by: Rajdeep Chandra <[email protected]>
1 parent c067f66 commit 700489f

File tree

3 files changed

+107
-1
lines changed

3 files changed

+107
-1
lines changed

.changeset/slimy-terms-hang.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@spectrum-web-components/tooltip': patch
3+
---
4+
5+
docs: add DelayedTooltipWithOverlay story demonstrating how to handle interactions between delayed tooltips and other overlay components

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ parameters:
1414
# 3. Commit this change to the PR branch where the changes exist.
1515
current_golden_images_hash:
1616
type: string
17-
default: 3412e93be28e587e2ded76d6c19d051e401e2623
17+
default: b7ea01b7daaccc2c345f09b26beb38c0a3791f8b
1818
wireit_cache_name:
1919
type: string
2020
default: wireit

packages/tooltip/stories/tooltip.stories.ts

+101
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import '@spectrum-web-components/textfield/sp-textfield.js';
2222
import '@spectrum-web-components/action-button/sp-action-button.js';
2323
import { Placement } from '@spectrum-web-components/overlay';
2424
import '@spectrum-web-components/overlay/sp-overlay.js';
25+
import '@spectrum-web-components/popover/sp-popover.js';
26+
import '@spectrum-web-components/overlay/overlay-trigger.js';
27+
// Import Overlay type for type casting
28+
import type { Overlay } from '@spectrum-web-components/overlay';
2529

2630
const iconOptions: {
2731
[key: string]: ({
@@ -454,3 +458,100 @@ draggable.parameters = {
454458
// Disables Chromatic's snapshotting on a global level
455459
chromatic: { disableSnapshot: true },
456460
};
461+
462+
export const DelayedTooltipWithOverlay = (): TemplateResult => {
463+
return html`
464+
<div
465+
style="width: 100%; max-width: 800px; margin: 0 auto; padding: 20px;"
466+
>
467+
<h2>Delayed Tooltip Overlay Interaction Issue</h2>
468+
469+
<div style="display: flex; gap: 24px; margin-bottom: 24px;">
470+
<!-- First overlay - this should stay open during tooltip warmup -->
471+
<sp-button variant="primary" id="button1">
472+
Click to Open Popover
473+
</sp-button>
474+
<sp-overlay
475+
trigger="button1@click"
476+
placement="bottom"
477+
id="popover-overlay"
478+
>
479+
<sp-popover>
480+
<div style="padding: 20px;">
481+
<h3 style="margin-top: 0;">Opened Popover</h3>
482+
<p>
483+
This popover should stay open during tooltip
484+
warmup
485+
</p>
486+
<p>
487+
<strong>Steps to test:</strong>
488+
With this popover open, hover the button to the
489+
right.
490+
</p>
491+
</div>
492+
</sp-popover>
493+
</sp-overlay>
494+
495+
<overlay-trigger triggered-by="hover">
496+
<sp-button
497+
slot="trigger"
498+
variant="secondary"
499+
@pointerenter=${(event: Event) => {
500+
// Capture phase event handler to stop propagation during warmup
501+
// This ensures other overlays don't close prematurely
502+
event.stopPropagation();
503+
}}
504+
>
505+
Hover me
506+
</sp-button>
507+
<sp-tooltip
508+
slot="hover-content"
509+
delayed
510+
placement="bottom"
511+
@sp-opened=${() => {
512+
const popoverOverlay = document.getElementById(
513+
'popover-overlay'
514+
) as Overlay;
515+
if (
516+
popoverOverlay &&
517+
popoverOverlay.hasAttribute('open')
518+
) {
519+
popoverOverlay.open = false;
520+
}
521+
}}
522+
>
523+
This is a delayed tooltip
524+
</sp-tooltip>
525+
</overlay-trigger>
526+
</div>
527+
528+
<div
529+
style="border: 1px solid #ccc; padding: 20px; border-radius: 4px; background-color: #f5f5f5;"
530+
>
531+
<h3 style="margin-top: 0;">Expected Behavior</h3>
532+
<ol style="margin-left: 16px;">
533+
<li>
534+
Click the
535+
<strong>Click to Open Popover</strong>
536+
button to open the popover
537+
</li>
538+
<li>
539+
Hover over the
540+
<strong>Hover me</strong>
541+
button
542+
</li>
543+
<li>
544+
The popover should
545+
<strong>remain open</strong>
546+
during the tooltip's 1-second warmup period
547+
</li>
548+
<li>
549+
The popover should
550+
<strong>automatically close</strong>
551+
when the tooltip appears in DOM
552+
</li>
553+
</ol>
554+
</div>
555+
</div>
556+
`;
557+
};

0 commit comments

Comments
 (0)