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

React: Don't show decorators in JSX snippets #21907

Merged
merged 6 commits into from
Apr 5, 2023

Conversation

tmeasday
Copy link
Member

@tmeasday tmeasday commented Apr 4, 2023

Telescoping on #21902

An alternate solution for #21649

What I did

Always move the JSX decorator to the end of the list, so it avoids all other decorators, as we can't see "inside" decorators in React. However we still need to actually render all the decorators as the story may depend on them.

TODO:

  • Figure out type issue with decorated.
  • Add an option to disable this behaviour.

How to test

See stories in this PR:

image

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

tmeasday added 2 commits April 4, 2023 17:25
This is a bit of a hacky way to acheive `excludeDecorators` without actually excluding them.
@JReinhold
Copy link
Contributor

I think this is an interesting solution.

  1. Does it make sense to do something similar for all renderers?
  2. Long-term, if we want to unbundle addon-docs as much as possible from the renderers, this would cause trouble right? Then we can't just import the jsxDecorator into the renderer anymore. I wonder if we should instead allow decorators to set some sort of ID on themselves for situations like this. This is very long-term though.

@tmeasday
Copy link
Member Author

tmeasday commented Apr 4, 2023

@JReinhold as far as we currently understand it, the issue is only a problem for react (well maybe there's an issue in that you see all the decorators in other frameworks but at least you see the story inside them).

So we think as a patch release a localised fix like this is a good idea.

Probably a better solution would be some 1st class way to declare a decorator as an "story inspector" or something so it gets wrapped inside the other decorators. Unless we can find a better solution I'd propose that as a 7.1 PR

@tmeasday tmeasday marked this pull request as ready for review April 5, 2023 11:45
@tmeasday tmeasday requested a review from shilman April 5, 2023 11:47
@tmeasday tmeasday added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Apr 5, 2023
Base automatically changed from shilman/21900-revert-source-exclude-decorators to next April 5, 2023 12:53
@shilman shilman changed the title React: don't show decorators in JSX snippets. React: Don't show decorators in JSX snippets Apr 5, 2023
@shilman shilman merged commit fcecd47 into next Apr 5, 2023
@shilman shilman deleted the tom/21649-change-react-decorator-order branch April 5, 2023 12:55
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label Apr 6, 2023
shilman added a commit that referenced this pull request Apr 6, 2023
…orator-order

React: Don't show decorators in JSX snippets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch react
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants