Skip to content

Commit ea079bc

Browse files
committed
fix: Remove focus before taking a screenshot in AddGranteeBase
risk: nonprod JIRA: LX-729
1 parent 0d0e813 commit ea079bc

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

Diff for: libs/sdk-ui-tests/stories/utils/useResetFocus.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// (C) 2025 GoodData Corporation
2+
import React from "react";
3+
4+
export const useResetFocus = (delay: number = 0): void => {
5+
React.useEffect(() => {
6+
const timeout = setTimeout(() => {
7+
(document.activeElement as HTMLElement | null)?.blur();
8+
}, delay);
9+
10+
return () => {
11+
clearTimeout(timeout);
12+
};
13+
}, [delay]);
14+
};

Diff for: libs/sdk-ui-tests/stories/visual-regression/kit/ShareDialog/AddGranteeBase.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// (C) 2021 GoodData Corporation
1+
// (C) 2021-2025 GoodData Corporation
22
import React from "react";
33
import { storiesOf } from "../../../_infra/storyRepository.js";
44
import { action } from "@storybook/addon-actions";
@@ -23,6 +23,7 @@ import { recordedBackend } from "@gooddata/sdk-backend-mockingbird";
2323
import { ReferenceRecordings } from "@gooddata/reference-workspace";
2424
import { idRef } from "@gooddata/sdk-model";
2525
import { LabelsMock } from "./LabelsMock.js";
26+
import { useResetFocus } from "../../../utils/useResetFocus.js";
2627

2728
const sharedObject: IAffectedSharedObject = {
2829
ref: idRef("object"),
@@ -166,6 +167,8 @@ const SelectedItemsExample = (): JSX.Element => {
166167
* @internal
167168
*/
168169
export const AddGranteeExamples = (): JSX.Element => {
170+
useResetFocus(200);
171+
169172
return (
170173
<InternalIntlWrapper>
171174
<div className="library-component screenshot-target">
@@ -189,5 +192,9 @@ export const AddGranteeExamples = (): JSX.Element => {
189192
};
190193

191194
storiesOf(`${UiKit}/ShareDialog/AddGranteeBase`)
192-
.add("full-featured", () => <AddGranteeExamples />, { screenshot: true })
193-
.add("themed", () => wrapWithTheme(<AddGranteeExamples />), { screenshot: true });
195+
.add("full-featured", () => <AddGranteeExamples />, {
196+
screenshot: { delay: 300 },
197+
})
198+
.add("themed", () => wrapWithTheme(<AddGranteeExamples />), {
199+
screenshot: { delay: 300 },
200+
});

0 commit comments

Comments
 (0)