fix(inspector): disable highlight during screenshot actions (#18621)

Fixes #18049.
This commit is contained in:
Dmitry Gozman 2022-11-07 13:53:15 -08:00 committed by GitHub
parent 9172a2ca5a
commit 1cee65722b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,14 +151,18 @@ export class Recorder implements InstrumentationListener {
});
await this._context.exposeBinding('__pw_recorderState', false, source => {
let actionSelector = this._highlightedSelector;
let actionSelector = '';
let actionPoint: Point | undefined;
const hasActiveScreenshotCommand = [...this._currentCallsMetadata.keys()].some(isScreenshotCommand);
if (!hasActiveScreenshotCommand) {
actionSelector = this._highlightedSelector;
for (const [metadata, sdkObject] of this._currentCallsMetadata) {
if (source.page === sdkObject.attribution.page) {
actionPoint = metadata.point || actionPoint;
actionSelector = actionSelector || metadata.params.selector;
}
}
}
const uiState: UIState = {
mode: this._mode,
actionPoint,
@ -235,7 +239,9 @@ export class Recorder implements InstrumentationListener {
this._currentCallsMetadata.set(metadata, sdkObject);
this._updateUserSources();
this.updateCallLog([metadata]);
if (metadata.params && metadata.params.selector) {
if (isScreenshotCommand(metadata)) {
this.hideHighlightedSelecor();
} else if (metadata.params && metadata.params.selector) {
this._highlightedSelector = metadata.params.selector;
this._recorderApp?.setSelector(this._highlightedSelector).catch(() => {});
}
@ -675,3 +681,7 @@ class ThrottledFile {
this._text = undefined;
}
}
function isScreenshotCommand(metadata: CallMetadata) {
return metadata.method.includes('screenshot');
}