fix(plugin-autocapture-browser): fix nearest label CSS coping - #1964
Open
daniel-graham-amplitude wants to merge 1 commit into
Open
fix(plugin-autocapture-browser): fix nearest label CSS coping#1964daniel-graham-amplitude wants to merge 1 commit into
daniel-graham-amplitude wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Regression test expects wrong label
- Nested the page-title h1 under a header so the fixture exercises unscoped descendant matching instead of a sibling :scope>h1 hit.
Or push these changes by commenting:
@cursor push a728934667
Preview (a728934667)
diff --git a/packages/plugin-autocapture-browser/test/data-extractor.test.ts b/packages/plugin-autocapture-browser/test/data-extractor.test.ts
--- a/packages/plugin-autocapture-browser/test/data-extractor.test.ts
+++ b/packages/plugin-autocapture-browser/test/data-extractor.test.ts
@@ -472,11 +472,13 @@
// the parent. Walking up then picks the first ancestor that contains any
// heading — e.g. a page title — instead of a sibling label.
const container = document.createElement('div');
+ const header = document.createElement('header');
const heading = document.createElement('h1');
heading.innerText = 'My App';
const form = document.createElement('form');
const input = document.createElement('input');
- container.appendChild(heading);
+ header.appendChild(heading);
+ container.appendChild(header);
form.appendChild(input);
container.appendChild(form);You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 7a19102. Configure here.
|
|
||
| const result = dataExtractor.getNearestLabel(input); | ||
| expect(result).toEqual(''); | ||
| }); |
There was a problem hiding this comment.
Regression test expects wrong label
Medium Severity
The new regression fixture puts the h1 as a direct child of container, so walking up from input still matches :scope>h1 and returns My App instead of ''. That tree does not reproduce the unscoped descendant-heading case this change fixes.
Reviewed by Cursor Bugbot for commit 7a19102. Configure here.
size-limit report 📦
|
daniel-graham-amplitude
force-pushed
the
SDK-229-fix-nearest-label
branch
from
August 31, 2026 17:23
7a19102 to
346f9ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Checklist
Note
Low Risk
Narrow DOM-query fix in autocapture label enrichment with a targeted regression test; no auth, persistence, or API surface changes.
Overview
Fixes incorrect
[Amplitude] Element Parent Labelvalues when a page has headings that are not direct siblings of the interacted element (e.g. a page titleh1above a nested form input).getNearestLabelnow applies:scope>to every selector in thequerySelectorlist (spanandh1–h6), so only direct child label elements are considered at each ancestor step. Previously, comma-separatedh1–h6without:scope>could match any descendant heading under the current parent, causing unrelated titles to be picked up while walking up the DOM.A regression test asserts that an input inside a nested form does not inherit a container-level
h1as its nearest label.Reviewed by Cursor Bugbot for commit 346f9ef. Bugbot is set up for automated code reviews on this repo. Configure here.