hypothesis / hypothesis/client

Client does not respond to `data-hypothesis-trigger` elements added to page after client loads

Open
#2,781 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Mustache
Stars
730
Forks
224
PR merge metrics
No merged PRs in 30d

Description

Issue originally reported here: https://hypothesis-open.slack.com/archives/C6Y375TT3/p1606558165041600

> I have a button with "data-hypothesis-trigger" but this does not seem to work when the page is changed using javascript. Anyway to manually trigger the sidebar open using javascript?

**Steps to reproduce:**

1. Add an element to the page with the `data-hypothesis-trigger` attribute set after the client has loaded.
2. Click on the element

**Expected result:** Sidebar opens
**Actual result:** Sidebar does not open

**Notes:**

If the element is on the page before the client loads, the button should work.

The code that [installs the trigger](https://github.com/hypothesis/client/blob/09a586c2d4699b9ff92104171f833ba550aea399/src/annotator/sidebar-trigger.js#L11) does so directly on the elements in the document with this attribute set and only once during client startup.

We could avoid this problem using event delegation.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.