-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Fixed layout shift issue when Search popup appears #22539
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request introduces changes within the Assessment against linked issues
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (5)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/sodo-search/src/App.js
(3 hunks)
🔇 Additional comments (4)
apps/sodo-search/src/App.js (4)
28-29
: State variable addition looks good.Adding the
scrollbarWidth
state variable to track the browser's scrollbar width is a good approach for addressing the layout shift issue.
36-38
: Proper initialization in componentDidMount.Good implementation of scrollbar width calculation during component initialization. This ensures the value is available before the popup is first displayed.
49-54
: Good implementation for opening popup.Storing the current margin-right value and then adding the scrollbar width when the popup opens is a solid approach to prevent layout shift. The conditional check ensures that the margin is only adjusted when there's a scrollbar width to account for.
57-61
: Good implementation for closing popup.The conditional handling for different margin scenarios when closing the popup is well implemented. It correctly handles cases where the original margin was 0px or empty, ensuring the DOM returns to its original state.
Fix #22538
Reference #21895
Got some code for us? Awesome 🎊!
Please include a description of your change & check your PR against this list, thanks!
yarn test:all
andyarn lint
)We appreciate your contribution!