Skip to content

Fix Share dialog rendering broken QR code image when qrCode is disabled - #11795

Open
Dmitriy Antipov (THEb0nny) wants to merge 1 commit into
microsoft:masterfrom
THEb0nny:fix/share-qrcode
Open

Dmitriy Antipov (THEb0nny) wants to merge 1 commit into
microsoft:masterfrom
THEb0nny:fix/share-qrcode

Conversation

@THEb0nny

Copy link
Copy Markdown
Contributor

Summary

In webapp/src/app.tsx (getShareUrl), shareData.qr is only populated when pxt.appTarget.appTheme.qrCode is enabled:

if (targetTheme.qrCode) {
    shareData.qr = await qr.renderAsync(`${shareUrl}${pubId}`);
}

However, in react-common/components/share/ShareInfo.tsx, the .project-qrcode button and its <img className="qrcode-image" src={shareData?.qr} ... /> were rendered unconditionally after publishing, resulting in a broken image in the "Share Project" dialog when qrCode is false (or shareData.qr is undefined).

Changes

  • react-common/components/share/ShareInfo.tsx:
    • Only render the .project-qrcode button when shareData?.qr is truthy.
    • Guard the QR code modal with showQRCode && shareData?.qr as well.

Testing

  • Ran npx gulp webapp (reactCommon, pxtblocks, pxteditor, pxtservices, webapp, browserifyWebapp, browserifyAssetEditor) — passed.
  • Ran npm run lint (gulp lint) — passed.
  • Verified locally with pxt-ev3 ("qrCode": false in pxtarget.json): the "Share Project" dialog no longer renders the broken QR code button/image after publishing.
Screenshot_15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant