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

fix(code-block): fix language-undefined in MDX CodeTabs #768

Merged
merged 2 commits into from
Oct 20, 2022

Conversation

zchsh
Copy link
Contributor

@zchsh zchsh commented Oct 19, 2022

🎟️ Asana Task
πŸ” Preview Link


Fixes a bug where shell-session snippets within CodeTabs would copy correctly via the Copy button, but would still include the $ character when selected and copied by clicking and dragging.

Details

Removes a className attribute that passed a non-existent className, which also dropped any incoming classNames. This was originally intended to prevent the possibility of custom styling via MDX, but has the side-effect of dropping the language-<language> class. That language class was unused for the most part (highlighting happens on the server!), but has become important for full functionality since #736 shipped.

This approach has been proven out in hashicorp/dev-portal#1268. Screenshots below are from that PR, demonstrating that with this fix, we go from the issue-causing language-undefined to language-shell-session.

Before

before

After

after

PR Checklist πŸš€

Items in this checklist may not may not apply to your PR, but please consider each item carefully.

  • Add Asana and Preview links above.
  • Conduct thorough self-review.
  • Add or update tests as appropriate.
  • Conduct reasonable cross browser testing for both compatibility and responsive behavior (We have a Sauce Labs account for this, if you don't have access, just ask!).
  • Conduct reasonable accessibility review (use the WAS as a guide or an axe browser plugin until we establish more formal checks).
  • Identify (in the description above) and document (add Asana tasks on this board) any technical debt that you're aware of, but are not addressing as part of this PR.

@zchsh zchsh added the release:canary Triggers a canary release for commits to this pull request label Oct 19, 2022
@changeset-bot
Copy link

changeset-bot bot commented Oct 19, 2022

πŸ¦‹ Changeset detected

Latest commit: f15c0a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hashicorp/react-code-block Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 19, 2022

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated
react-components βœ… Ready (Inspect) Visit Preview Oct 19, 2022 at 11:57PM (UTC)

@github-actions
Copy link
Contributor

πŸ“¦ Canary Packages Published

Latest commit: f15c0a3

Published 1 packages

@hashicorp/react-code-block@6.2.1-canary-20221019235743

npm install @hashicorp/react-code-block@canary

@zchsh zchsh requested a review from BRKalow October 20, 2022 00:36
@zchsh zchsh marked this pull request as ready for review October 20, 2022 00:36
@zchsh zchsh changed the title fix: fix language-undefined in MDX CodeTabs fix(code-block): fix language-undefined in MDX CodeTabs Oct 20, 2022
Copy link
Contributor

@BRKalow BRKalow left a comment

Choose a reason for hiding this comment

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

Good catch! Do you think there's any reason why we would want to retain the ignoring of other passed className values?

@zchsh
Copy link
Contributor Author

zchsh commented Oct 20, 2022

@BRKalow I think my previous reasoning was to try to preemptively prevent any custom styling in MDX contexts. But in retrospect I don't think that made all that much sense, custom styling would probably happen through the style prop anyways? πŸ€” So I don't see any strong reason to retain the "ignore incoming className" behaviour.

@BRKalow
Copy link
Contributor

BRKalow commented Oct 20, 2022

Makes sense, thanks for the insight!

@zchsh zchsh merged commit 95c749e into main Oct 20, 2022
@zchsh zchsh deleted the zs.fix-code-tabs-language branch October 20, 2022 14:06
@hashibot-web hashibot-web mentioned this pull request Oct 20, 2022
alexcarpenter pushed a commit that referenced this pull request Oct 21, 2022
* fix: fix language-undefined in MDX CodeTabs

* chore(code-block): add changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:canary Triggers a canary release for commits to this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants