Skip to content

Add hover trigger support for tooltip-style popups - #14

Merged
roborourke merged 5 commits into
mainfrom
claude/ecstatic-goodall-VAzNU
Aug 7, 2026
Merged

roborourke merged 5 commits into
mainfrom
claude/ecstatic-goodall-VAzNU

Conversation

@roborourke

@roborourke roborourke commented May 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #12

Summary

Adds a new hover trigger so popups open when a visitor hovers over any element that links to the popup anchor. Unlike the other triggers, hover uses dialog.show() (non-modal) rather than dialog.showModal(), so there is no backdrop dimming and no focus trap — the right behaviour for tooltips.

Changes

src/block.json

  • Added "hover" to the trigger attribute enum.

src/edit.js

  • Added On hover option to the Popup Trigger SelectControl.
  • Shows the Anchor / ID field for hover (same link-based mechanism as click).
  • Added a description note recommending the Anchored block style for best results.
  • Cookie expiration control is hidden for hover (it's not a one-time modal).

src/view.js

  • New hover handler inside bootstrap():
    • Opens the popup with popup.show() on mouseenter / focus on any [href="#<id>"] trigger.
    • Closes on mouseleave / blur of the trigger, unless the cursor has moved onto the popup itself.
    • Closes when the cursor leaves the popup, unless it has returned to a trigger element.
    • CSS anchor positioning is applied automatically when the Anchored block style is active.

src/variations.js

  • The Open Popup button variation now also lists hover-triggered popups in the selector dropdown (same href="#id" mechanism).

tests/popup-options.spec.js

  • Added E2E tests covering: option presence, attribute serialisation, anchor/ID field visibility, cookie expiration hiding, data-trigger output, and frontend mouseenter behaviour.

How to test

  1. Create a new post, insert a Popup block.
  2. In the sidebar, set Popup Trigger → On hover.
  3. Confirm the Anchor / ID field appears and Cookie expiration is hidden.
  4. Apply the Anchored block style and set an anchor ID (e.g. my-tooltip).
  5. Insert a paragraph with a link href="#my-tooltip".
  6. Publish and visit the frontend — hovering over the link should open the popup positioned relative to the link; moving away should close it.

https://claude.ai/code/session_01SjvQ7YTxjFF81uSb1WtPAH


Generated by Claude Code

Open WordPress Playground Preview

claude added 2 commits May 27, 2026 12:10
Implements issue #12. Adds a new 'hover' trigger that opens the popup
using dialog.show() (non-modal) when the visitor hovers over any element
linking to the popup anchor, providing better tooltip behaviour without
the modal backdrop or focus trap.

Changes:
- block.json: add 'hover' to the trigger enum
- edit.js: add 'On hover' option to trigger SelectControl, show
  anchor/ID field for hover (same as click), add description note
  suggesting the Anchored style, exclude cookie expiration for hover
- view.js: add hover handler using mouseenter/mouseleave and
  focus/blur for keyboard accessibility; popup stays open when
  cursor moves from trigger to popup; CSS anchor positioning applied
  when is-style-anchored is active
- variations.js: include hover-triggered popups in the Open Popup
  button variation selector (same link-based mechanism as click)
- tests: add E2E tests for hover trigger option, anchor/ID field
  visibility, cookie expiration hiding, data-trigger output, and
  frontend mouseenter behaviour

https://claude.ai/code/session_01SjvQ7YTxjFF81uSb1WtPAH
Implements issue #13. Adds a 'Popups' pattern category and six ready-to-use
block patterns so users can get started without building popups from scratch.

Changes:
- popup.php: register 'hm-popup' pattern category in action_init(); load
  and register pattern definitions from the new patterns/ directory using
  register_block_pattern()
- patterns/exit-intent.php: exit intent popup with close button and
  a core/group with the 'natural' WP box shadow
- patterns/page-load.php: page load popup with close button and
  a core/group with the 'natural' WP box shadow
- patterns/click-popup.php: trigger button + click popup with close
  button and a core/group with the 'natural' WP box shadow
- patterns/left-popout.php: left slide-in panel (is-style-side--left),
  click trigger, first inner group has minHeight 100vh and a grey right border
- patterns/right-popout.php: right slide-in panel (is-style-side--right),
  click trigger, first inner group has minHeight 100vh and a grey left border
- patterns/tooltip.php: anchored tooltip (is-style-anchored, anchorPosition top)
  triggered by hovering an info icon; uses the hover trigger from #12

https://claude.ai/code/session_01SjvQ7YTxjFF81uSb1WtPAH
@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown

Playwright E2E Test Results (PHP 8.4, WP latest)

passed  25 passed

Details

stats  25 tests across 3 suites
duration  2 minutes, 43 seconds
commit  f06d169

claude added 2 commits May 27, 2026 12:29
…gger

The beforeEach hook inserts a click-triggered popup, so the hover
frontend test had two .wp-block-hm-popup elements on the page.
Playwright's toHaveAttribute throws on multiple matches, causing CI
to fail.

Fixes:
- Use '#hover-test-popup' selector instead of '.wp-block-hm-popup' to
  target only the hover popup, avoiding ambiguity with the click popup
  inserted by beforeEach
- Replace raw paragraph HTML link with core/buttons + core/button
  (same pattern used in anchoring.spec.js) for a reliable trigger
- Check toHaveAttribute('open', '') after hover to precisely assert
  that dialog.show() was called (sets the open attribute)

https://claude.ai/code/session_01SjvQ7YTxjFF81uSb1WtPAH
…gger

The beforeEach hook inserts a click-triggered popup, so the hover
frontend test had two .wp-block-hm-popup elements on the page.
Playwright's toHaveAttribute throws on multiple matches, causing CI
to fail.

Fixes:
- Use '#hover-test-popup' selector instead of '.wp-block-hm-popup' to
  target only the hover popup, avoiding ambiguity with the click popup
  inserted by beforeEach
- Replace raw paragraph HTML link with core/buttons + core/button
  (same pattern used in anchoring.spec.js) for a reliable trigger
- Check toHaveAttribute('open', '') after hover to precisely assert
  that dialog.show() was called (sets the open attribute)

https://claude.ai/code/session_01SjvQ7YTxjFF81uSb1WtPAH
github-actions Bot added a commit that referenced this pull request May 27, 2026
…atterns

Register out-of-the-box block patterns
github-actions Bot added a commit that referenced this pull request Jul 20, 2026
@roborourke
roborourke merged commit 57e5500 into main Aug 7, 2026
4 checks passed
@roborourke
roborourke deleted the claude/ecstatic-goodall-VAzNU branch August 7, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add hover trigger support for better tooltip behaviour

3 participants