Skip to content

Commit 26be096

Browse files
committed
fixes
1 parent 73d6fb1 commit 26be096

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

code/core/src/manager/components/preview/tools/share.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { global } from '@storybook/global';
55
import type { StoryObj } from '@storybook/react-vite';
66

77
import { ManagerContext } from 'storybook/manager-api';
8-
import { expect, screen, waitFor } from 'storybook/test';
8+
import { expect, fn, screen, waitFor } from 'storybook/test';
99

1010
import { shareTool } from './share';
1111

@@ -15,6 +15,7 @@ const managerContext = {
1515
refId: undefined,
1616
},
1717
api: {
18+
emit: fn().mockName('api::emit'),
1819
getShortcutKeys: () => ({
1920
copyStoryLink: ['alt', 'shift', 'l'],
2021
openInIsolation: ['alt', 'shift', 'i'],

code/core/src/manager/components/preview/tools/share.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useMemo, useState } from 'react';
1+
import React, { useEffect, useMemo, useState } from 'react';
22

33
import { Button, PopoverProvider, TooltipLinkList } from 'storybook/internal/components';
44
import {
@@ -76,11 +76,14 @@ const ShareMenu = React.memo(function ShareMenu({
7676
const copyStoryLink = shortcutKeys?.copyStoryLink;
7777
const openInIsolation = shortcutKeys?.openInIsolation;
7878

79+
useEffect(() => {
80+
api.emit(SHARE_POPOVER_OPENED);
81+
}, [api]);
82+
7983
const links = useMemo(() => {
8084
const copyTitle = copied ? 'Copied!' : 'Copy story link';
8185
const originHrefs = api.getStoryHrefs(storyId, { base: 'origin', refId });
8286
const networkHrefs = api.getStoryHrefs(storyId, { base: 'network', refId });
83-
api.emit(SHARE_POPOVER_OPENED);
8487

8588
return [
8689
[

0 commit comments

Comments
 (0)