Skip to content

fix: Remove focus before taking a screenshot in AddGranteeBase #6233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions libs/sdk-ui-tests/stories/utils/useResetFocus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// (C) 2025 GoodData Corporation
import React from "react";

export const useResetFocus = (delay: number = 0): void => {
React.useEffect(() => {
const timeout = setTimeout(() => {
(document.activeElement as HTMLElement | null)?.blur();
}, delay);

return () => {
clearTimeout(timeout);
};
}, [delay]);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) 2021 GoodData Corporation
// (C) 2021-2025 GoodData Corporation
import React from "react";
import { storiesOf } from "../../../_infra/storyRepository.js";
import { action } from "@storybook/addon-actions";
Expand All @@ -23,6 +23,7 @@ import { recordedBackend } from "@gooddata/sdk-backend-mockingbird";
import { ReferenceRecordings } from "@gooddata/reference-workspace";
import { idRef } from "@gooddata/sdk-model";
import { LabelsMock } from "./LabelsMock.js";
import { useResetFocus } from "../../../utils/useResetFocus.js";

const sharedObject: IAffectedSharedObject = {
ref: idRef("object"),
Expand Down Expand Up @@ -166,6 +167,8 @@ const SelectedItemsExample = (): JSX.Element => {
* @internal
*/
export const AddGranteeExamples = (): JSX.Element => {
useResetFocus(200);

return (
<InternalIntlWrapper>
<div className="library-component screenshot-target">
Expand All @@ -189,5 +192,9 @@ export const AddGranteeExamples = (): JSX.Element => {
};

storiesOf(`${UiKit}/ShareDialog/AddGranteeBase`)
.add("full-featured", () => <AddGranteeExamples />, { screenshot: true })
.add("themed", () => wrapWithTheme(<AddGranteeExamples />), { screenshot: true });
.add("full-featured", () => <AddGranteeExamples />, {
screenshot: { delay: 300 },
})
.add("themed", () => wrapWithTheme(<AddGranteeExamples />), {
screenshot: { delay: 300 },
});
Loading