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(type-aliases): add title prop for imported inline SVG React components #9612

Merged
merged 2 commits into from
Dec 5, 2023
Merged

fix(type-aliases): add title prop for imported inline SVG React components #9612

merged 2 commits into from
Dec 5, 2023

Conversation

axmmisaka
Copy link
Contributor

@axmmisaka axmmisaka commented Dec 4, 2023

This PR would make TypeScript server stop complaining should one decide to use the "title" prop in imported inline SVG elements

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior. (this PR involves only typechecking and I don't think it's applicable)
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

fix #9609; this PR changes typing interface to adapt webpack behaviour.

Test Plan

  1. Open up docusaurus.new and yarn install this change
  2. In src/components/HomePageFeatures (or any other place), do
import Mountain from '@site/static/img/undraw_docusaurus_mountain.svg';
const test = (): JSX.Element => (
<>
    <Mountain role="img" />
    <Mountain role="img" title="Wow cool dinosaur" />
</>);
  1. Run yarn typecheck
  2. Confirm that tsc does not complain

Test links

https://stackblitz.com/edit/github-sdux4y?file=src%2Fcomponents%2FHomepageFeatures%2Findex.tsx&view=editor

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

#9609

This would make TypeScript server stop complaining should one decide to use the "title" prop

Relate issue: #9609
@axmmisaka axmmisaka requested a review from slorber as a code owner December 4, 2023 19:53
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 4, 2023
Copy link

netlify bot commented Dec 4, 2023

[V2]

Name Link
🔨 Latest commit 1d155bf
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/656f4d30bde6d80008fe5aff
😎 Deploy Preview https://deploy-preview-9612--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Dec 4, 2023

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 78 🟢 98 🟢 100 🟢 100 🟠 89 Report
/docs/installation 🟠 71 🟢 98 🟢 100 🟢 100 🟠 89 Report
/docs/category/getting-started 🟠 76 🟢 100 🟢 100 🟢 90 🟠 89 Report
/blog 🟠 74 🟢 100 🟢 100 🟢 90 🟠 89 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 63 🟢 97 🟢 100 🟢 100 🟠 89 Report
/blog/tags/release 🟠 75 🟢 100 🟢 100 🟠 80 🟠 89 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟢 90 🟠 89 Report

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Dec 5, 2023
@slorber
Copy link
Collaborator

slorber commented Dec 5, 2023

LGTM thanks 👍

Fix #9609

Note: title is not a valid svg attribute, and this SVGR prop gets mapped to a child <title> element, as documented in gregberge/svgr#88

import SvgrComponent from './SvgrComponent'

<SvgrComponent title="This is a title" />
// The output will be:
// <svg><title>This is a title</title></svg>
// Instead of:
// <svg title="This is a title" />

@slorber slorber added the to backport This PR is planned to be backported to a stable version of Docusaurus label Dec 5, 2023
@slorber slorber merged commit 8dd1e13 into facebook:main Dec 5, 2023
30 of 31 checks passed
@axmmisaka axmmisaka deleted the title-prop-for-inline-svg branch December 8, 2023 11:27
slorber added a commit that referenced this pull request Jan 5, 2024
…ponents (#9612)

Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
slorber added a commit that referenced this pull request Jan 5, 2024
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
Co-authored-by: Ivan Mar (sOkam!) <7308253+heysokam@users.noreply.github.com>
Co-authored-by: c0h1b4 <dwidman@gmail.com>
Co-authored-by: Janessa Garrow <janessa.garrow@gmail.com>
Co-authored-by: ozaki <29860391+OzakIOne@users.noreply.github.com>
Co-authored-by: axmmisaka <6500159+axmmisaka@users.noreply.github.com>
Co-authored-by: Tatsunori Uchino <tats.u@live.jp>
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
fix(i18n): complete translations for theme-common.json Brazilian Portuguese (pt-BR) (#9477)
fix(content-blog): add baseUrl for author.image_url (#9581)
fix(type-aliases): add `title` prop for imported inline SVG React components (#9612)
fix(utils): Markdown link replacement with <> but no spaces (#9617)
fix(live-codeblock): stabilize react-live transformCode callback, fix editor/preview desync (#9631)
fix(cli): output help when no conventional config + no subcommand (#9648)
fix CI job (#9604)
fix Lint Autofix workflow (#9632)
fix(pwa-plugin): upgrade workbox (#9668)
fix(create-docusaurus): fix init template code blocks, and little improvements (#9696)
fix(theme): allow empty code blocks and live playgrounds (#9704)
@slorber slorber added backported This PR has been backported to a stable version of Docusaurus and removed to backport This PR is planned to be backported to a stable version of Docusaurus labels Jan 5, 2024
slorber added a commit that referenced this pull request Jan 26, 2024
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: Joey Clover <joey@popos.local>
Co-authored-by: reece-white <93522192+reece-white@users.noreply.github.com>
Co-authored-by: Shreesh Nautiyal <114166000+Shreesh09@users.noreply.github.com>
Co-authored-by: Nick Gerleman <nick@nickgerleman.com>
Co-authored-by: Chongyi Zheng <git@zcy.dev>
Co-authored-by: MCR Studio <99176216+mcrstudio@users.noreply.github.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
Co-authored-by: Ivan Mar (sOkam!) <7308253+heysokam@users.noreply.github.com>
Co-authored-by: c0h1b4 <dwidman@gmail.com>
Co-authored-by: Janessa Garrow <janessa.garrow@gmail.com>
Co-authored-by: ozaki <29860391+OzakIOne@users.noreply.github.com>
Co-authored-by: axmmisaka <6500159+axmmisaka@users.noreply.github.com>
Co-authored-by: Tatsunori Uchino <tats.u@live.jp>
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
Co-authored-by: Sanjaiyan Parthipan <parthipankalayini@gmail.com>
Co-authored-by: Jack Robson <143492403+jack-robson@users.noreply.github.com>
Co-authored-by: dawei-wang <dawei-wang@users.noreply.github.com>
Co-authored-by: eitsupi <50911393+eitsupi@users.noreply.github.com>
fix(create-docusaurus): fix readme docusaurus 2 ref (#9487)
fix(theme): fix firefox CSS :has() support bug (#9530)
fix(theme): docs html sidebar items should always be visible (#9531)
fix: v3 admonitions should support v2 title syntax for nested admonitions (#9535)
fix(theme-classic): fixed wrong cursor on dropdown menu in navbar, when window is small (#9398)
fix(theme): upgrade prism-react-renderer, fix html script and style tag highlighting (#9567)
fix: add v2 retrocompatible support for quoted admonitions (#9570)
fix(i18n): complete translations for theme-common.json Brazilian Portuguese (pt-BR) (#9477)
fix(content-blog): add baseUrl for author.image_url (#9581)
fix(type-aliases): add `title` prop for imported inline SVG React components (#9612)
fix(utils): Markdown link replacement with <> but no spaces (#9617)
fix(live-codeblock): stabilize react-live transformCode callback, fix editor/preview desync (#9631)
fix(cli): output help when no conventional config + no subcommand (#9648)
fix CI job (#9604)
fix Lint Autofix workflow (#9632)
fix(pwa-plugin): upgrade workbox (#9668)
fix(create-docusaurus): fix init template code blocks, and little improvements (#9696)
fix(theme): allow empty code blocks and live playgrounds (#9704)
fix(core): various broken anchor link fixes (#9732)
fix: remove old useless mdx typedefs (#9733)
fix(theme-common): fix missing code block MagicComments style in Visual Basic (.NET) 16 (#9727)
fix(core): conditionally include `hostname` parameter when using… (#9407)
fix(create-docusaurus): fix typo in init template sample docs (#9783)
fix(mdx-loader): allow spaces before `mdx-code-block` info string (#9776)
fix(core): links with target "_blank" should no be checked by the broken link checker (#9788)
fix(core): broken links optimization behaves differently than non-optimized logic (#9791)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR has been backported to a stable version of Docusaurus CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TS Server does not recognise title prop for loaded inline SVG components
3 participants