Skip to content

Commit a2d258f

Browse files
committed
fix checkbox/radio handler
1 parent 07201ce commit a2d258f

7 files changed

Lines changed: 23 additions & 14 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snyk-api-and-web-record-sequence",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Snyk API & Web Record login/sequence",
55
"license": "MIT",
66
"scripts": {

src/manifest-firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Snyk API & Web Sequence Recorder",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"browser_specific_settings": {
55
"gecko": {
66
"id": "sequence-recorder@probely.com",

src/pages/Content/modules/collectEvents.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,26 @@ export function interceptEvents(event, doc, ifrSelector, callback) {
201201
}
202202
const parentLabel = tgt.closest && tgt.closest('label');
203203
if (parentLabel) {
204-
const forAttr = parentLabel.getAttribute('for');
205-
if (forAttr) {
206-
const forEl = document.getElementById(forAttr);
207-
if (forEl && forEl.nodeName.toLowerCase() === 'input' &&
208-
(forEl.type === 'checkbox' || forEl.type === 'radio')) {
204+
// Only suppress when the click is actually forwarded to the labeled control.
205+
// Clicks on interactive descendants (links, buttons, other fields) are NOT
206+
// forwarded by the browser and must still be recorded.
207+
const interactiveHit = tgt.closest('a, button, input, select, textarea');
208+
const forwardsToControl = !interactiveHit || !parentLabel.contains(interactiveHit);
209+
if (forwardsToControl) {
210+
const forAttr = parentLabel.getAttribute('for');
211+
if (forAttr) {
212+
const root = tgt.getRootNode();
213+
const lookup = root && root.getElementById ? root : document; // shadow-DOM safe
214+
const forEl = lookup.getElementById(forAttr);
215+
if (forEl && forEl.nodeName.toLowerCase() === 'input' &&
216+
(forEl.type === 'checkbox' || forEl.type === 'radio')) {
217+
return;
218+
}
219+
}
220+
if (parentLabel.querySelector('input[type="checkbox"], input[type="radio"]')) {
209221
return;
210222
}
211223
}
212-
if (parentLabel.querySelector('input[type="checkbox"], input[type="radio"]')) {
213-
return;
214-
}
215224
}
216225
let typeStr = 'click';
217226
if (isCanvasSurface(tgt)) {

test-build-firefox/contentScript.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-build-firefox/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Snyk API & Web Sequence Recorder",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"browser_specific_settings": {
55
"gecko": {
66
"id": "sequence-recorder@probely.com",

test-build/contentScript.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"1.2.1","manifest_version":3,"name":"Snyk API & Web Sequence Recorder","action":{"default_popup":"popup.html","default_icon":{"16":"icon-34.png","48":"icon-48.png"}},"icons":{"128":"icon-128.png"},"background":{"service_worker":"background.bundle.js"},"content_scripts":[{"matches":["http://*/*","https://*/*"],"js":["contentScript.bundle.js"],"css":["content.styles.css"],"run_at":"document_start","all_frames":true,"match_about_blank":true}],"web_accessible_resources":[{"resources":["content.styles.css","icon-128.png","icon-34.png"],"matches":["<all_urls>"]}],"permissions":["storage","activeTab"],"host_permissions":["http://*/*","https://*/*"]}
1+
{"version":"1.2.2","manifest_version":3,"name":"Snyk API & Web Sequence Recorder","action":{"default_popup":"popup.html","default_icon":{"16":"icon-34.png","48":"icon-48.png"}},"icons":{"128":"icon-128.png"},"background":{"service_worker":"background.bundle.js"},"content_scripts":[{"matches":["http://*/*","https://*/*"],"js":["contentScript.bundle.js"],"css":["content.styles.css"],"run_at":"document_start","all_frames":true,"match_about_blank":true}],"web_accessible_resources":[{"resources":["content.styles.css","icon-128.png","icon-34.png"],"matches":["<all_urls>"]}],"permissions":["storage","activeTab"],"host_permissions":["http://*/*","https://*/*"]}

0 commit comments

Comments
 (0)