add trigger focus option to replayer, which may helps integration into other apps

This commit is contained in:
Yanzhen Yu
2020-02-28 19:48:36 +08:00
parent fa4b4299e7
commit 29296b6877
2 changed files with 4 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ export class Replayer {
blockClass: 'rr-block', blockClass: 'rr-block',
liveMode: false, liveMode: false,
insertStyleRules: [], insertStyleRules: [],
triggerFocus: true,
}; };
this.config = Object.assign({}, defaultConfig, config); this.config = Object.assign({}, defaultConfig, config);
@@ -494,6 +495,7 @@ export class Replayer {
type: d.type, type: d.type,
target, target,
}); });
const { triggerFocus } = this.config;
switch (d.type) { switch (d.type) {
case MouseInteractions.Blur: case MouseInteractions.Blur:
if (((target as Node) as HTMLElement).blur) { if (((target as Node) as HTMLElement).blur) {
@@ -501,7 +503,7 @@ export class Replayer {
} }
break; break;
case MouseInteractions.Focus: case MouseInteractions.Focus:
if (((target as Node) as HTMLElement).focus) { if (triggerFocus && ((target as Node) as HTMLElement).focus) {
((target as Node) as HTMLElement).focus({ ((target as Node) as HTMLElement).focus({
preventScroll: true, preventScroll: true,
}); });

View File

@@ -318,6 +318,7 @@ export type playerConfig = {
blockClass: string; blockClass: string;
liveMode: boolean; liveMode: boolean;
insertStyleRules: string[]; insertStyleRules: string[];
triggerFocus: boolean;
}; };
export type playerMetaData = { export type playerMetaData = {