Skip to content

Fix/qrcode layout shift - #1004

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
dominiccreates:fix/qrcode-layout-shift
Jul 27, 2026
Merged

Fix/qrcode layout shift#1004
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
dominiccreates:fix/qrcode-layout-shift

Conversation

@dominiccreates

Copy link
Copy Markdown
Contributor

Closes #973
This PR addresses an issue in src/components/QRCode.tsx where the outer render wrapper failed to reserve space prior to the canvas painting, causing unwanted layout shifting. Additionally, it optimizes how the component queries for the canvas element.

Key Changes:

Reserved Wrapper Dimensions: Added explicit width and height styling to the actual render wrapper (div), matching the fallback UI, to ensure the space is fully reserved before the QR canvas has painted.
Optimized onRender Canvas Query: Modified the useEffect hook to prevent it from re-querying the canvas redundantly on every color or size prop change. The dependency array was streamlined to only re-query when !!value flips (i.e. mount/unmount and when valid URL inputs toggle), reducing unnecessary DOM operations.

@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@dominiccreates Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit ae24f4b into rinafcode:main Jul 27, 2026
6 checks passed
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.

Reserve stable dimensions for the QRCode wrapper to prevent layout shift

2 participants