Skip to content

Commit

Permalink
cherry-pick(#33638): chore: clear highlight when performing action
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Nov 16, 2024
1 parent 2a00ca8 commit 53f51a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,10 @@ class RecordActionTool implements RecorderTool {
return;
const result = activeElement ? this._recorder.injectedScript.generateSelector(activeElement, { testIdAttributeName: this._recorder.state.testIdAttributeName }) : null;
this._activeModel = result && result.selector ? result : null;
if (userGesture)
if (userGesture) {
this._hoveredElement = activeElement as HTMLElement | null;
this._updateModelForHoveredElement();
this._updateModelForHoveredElement();
}
}

private _shouldIgnoreMouseEvent(event: MouseEvent): boolean {
Expand Down Expand Up @@ -589,6 +590,8 @@ class RecordActionTool implements RecorderTool {
}

private _updateModelForHoveredElement() {
if (this._performingActions.size)
return;
if (!this._hoveredElement || !this._hoveredElement.isConnected) {
this._hoveredModel = null;
this._hoveredElement = null;
Expand Down
11 changes: 0 additions & 11 deletions tests/library/inspector/cli-codegen-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,6 @@ await page1.GotoAsync("about:blank?foo");`);
await expect.poll(() => messages).toEqual(['mousedown', 'mouseup', 'click']);
});

test('should update hover model on action', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();

await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="checkbox.name='updated'"></input>`);
const [models] = await Promise.all([
recorder.waitForActionPerformed(),
page.click('input')
]);
expect(models.hovered).toBe('#checkbox');
});

test('should reset hover model on action when element detaches', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();

Expand Down

0 comments on commit 53f51a8

Please sign in to comment.