Skip to content
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

Composition: Hide contextMenu on composed storybooks #29803

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Dec 4, 2024

Closes #29686

What I did

I ensured that the code for creating the contextMenu never runs for refs

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

I manually verified the UI looks correct by:

  • Starting the monorepo storybook in dev-mode after building this change.

It looked like this (icons are from a reffed storybook):
Screenshot 2024-12-04 at 11 21 29

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 0 B 0.75 0%
initSize 130 MB 130 MB 108 B 0.13 0%
diffSize 52.4 MB 52.4 MB 108 B -0.01 0%
buildSize 6.75 MB 6.75 MB 108 B -1.52 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B - 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 108 B 1 0%
buildSbPreviewSize 0 B 0 B 0 B -1.53 -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.56 MB 3.57 MB 108 B -1.53 0%
buildPreviewSize 3.19 MB 3.19 MB 0 B 1.53 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 6.5s 27s 20.4s 1.5 🔺75.7%
generateTime 18.8s 20.8s 1.9s 0.1 9.4%
initTime 12.2s 14s 1.7s 0.14 12.7%
buildTime 8s 8.2s 127ms -1.05 1.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4s 4.5s 492ms -0.81 10.8%
devManagerResponsive 3s 3.4s 420ms -0.56 12.2%
devManagerHeaderVisible 468ms 554ms 86ms -0.42 15.5%
devManagerIndexVisible 497ms 590ms 93ms -0.66 15.8%
devStoryVisibleUncached 1.7s 1.2s -509ms -2.69 🔰-42.1%
devStoryVisible 497ms 591ms 94ms -0.57 15.9%
devAutodocsVisible 477ms 497ms 20ms -0.49 4%
devMDXVisible 455ms 549ms 94ms 0.15 17.1%
buildManagerHeaderVisible 479ms 546ms 67ms -0.4 12.3%
buildManagerIndexVisible 554ms 630ms 76ms -0.07 12.1%
buildStoryVisible 444ms 508ms 64ms -0.61 12.6%
buildAutodocsVisible 361ms 450ms 89ms -0.3 19.8%
buildMDXVisible 372ms 463ms 91ms -0.12 19.7%

Greptile Summary

Implemented a fix to prevent context menu from appearing in referenced (composed) Storybooks by modifying the sidebar Tree component's menu behavior.

  • Modified code/core/src/manager/components/sidebar/Tree.tsx to check for refId === 'storybook_internal' before showing context menu
  • Returns empty object with null node when story is from a referenced Storybook
  • Fixes issue [Bug]: Sidebar context menu behaves incorrectly in reffed entrys #29686 where context menu incorrectly appeared for referenced stories
  • Prevents invariant failures when accessing non-existent entries in composed Storybooks

@ndelangen ndelangen self-assigned this Dec 4, 2024
@ndelangen ndelangen changed the title Do not show contextMenu on refs Composition: Hide contextMenu on composed storybooks Dec 4, 2024
@ndelangen ndelangen marked this pull request as ready for review December 4, 2024 10:26
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +277 to +279
refId === 'storybook_internal'
? useContextMenu(item, statusLinks, api)
: { node: null, onMouseEnter: () => {} };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: consider using a constant for 'storybook_internal' to avoid magic strings

Copy link

nx-cloud bot commented Dec 4, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 8154eed. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@ndelangen ndelangen merged commit 4489350 into next Dec 4, 2024
60 of 61 checks passed
@ndelangen ndelangen deleted the norbert/sidebar-contextmenu-not-on-refs branch December 4, 2024 11:55
@github-actions github-actions bot mentioned this pull request Dec 4, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Sidebar context menu behaves incorrectly in reffed entrys
2 participants