Skip to content

Commit 120d6fe

Browse files
committed
Use capture phase for clicks
Ensure that the recorder sees the click before other listeners which could stop the click from bubbling and preventing the recording. Signed-off-by: thc202 <[email protected]>
1 parent 7dc6eca commit 120d6fe

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
### Added
99
- Support for dark mode
1010

11+
### Fixed
12+
- Record all clicks even when the site stops the events from bubbling.
13+
1114
## 0.1.6 - 2025-08-04
1215

1316
### Fixed

CHANGELOG.rec.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
### Added
99
- Support for dark mode
1010

11+
### Fixed
12+
- Record all clicks even when the site stops the events from bubbling.
13+
1114
## 0.1.6 - 2025-08-04
1215

1316
### Fixed

source/ContentScript/recorder.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,10 @@ class Recorder {
337337

338338
element.addEventListener(
339339
'click',
340-
this.handleClick.bind(this, {level, frame, element})
340+
this.handleClick.bind(this, {level, frame, element}),
341+
{
342+
capture: true,
343+
}
341344
);
342345
element.addEventListener(
343346
'scroll',

test/ContentScript/integrationTests.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,25 @@ function integrationTests(
240240
]);
241241
});
242242

243+
test('Should record click that does not bubble', async () => {
244+
// Given / When
245+
await driver.toggleRecording();
246+
const wd = await driver.getWebDriver();
247+
await wd.get(`http://localhost:${_HTTPPORT}/webpages/interactions.html`);
248+
await pageLoaded(wd);
249+
await wd.findElement(By.id('click-no-bubble')).click();
250+
await eventsProcessed();
251+
// Then
252+
expect(actualData).toEqual([
253+
reportZestStatementComment(),
254+
reportZestStatementLaunch(
255+
'http://localhost:1801/webpages/interactions.html'
256+
),
257+
reportZestStatementScrollTo(3, 'click-no-bubble'),
258+
reportZestStatementClick(4, 'click-no-bubble'),
259+
]);
260+
});
261+
243262
test('Should record click with start URL delay', async () => {
244263
// Given / When
245264
await driver.toggleRecording(

test/ContentScript/webpages/interactions.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
</head>
44
<body>
55
<button id="click">click me</button>
6+
<button id="click-no-bubble">click me no bubble</button>
67
<input type="text" id="input-1" />
78
<input type="date" id="input-2" />
89
<input type="text" id="input-3-filled" value="Existing text"/>
@@ -14,5 +15,9 @@
1415
<option value="audi">Audi</option>
1516
</select>
1617
<iframe src="./testFrame.html" name="frame1"></iframe>
18+
<script>
19+
const elem = document.getElementById("click-no-bubble");
20+
elem.addEventListener("click", (e) => e.stopPropagation());
21+
</script>
1722
</body>
1823
</html>

0 commit comments

Comments
 (0)