-
Notifications
You must be signed in to change notification settings - Fork 38
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: Modal内のDropdownSelectorの挙動修正 #384
Conversation
Size Change: +3.05 kB (+1%) Total Size: 582 kB
ℹ️ View Unchanged
|
Visit the preview URL for this PR (updated for commit f8bc858): https://pixiv-charcoal-web--pr384-toshusai-fix-dropdow-dmuoqo1y.web.app (expires Mon, 30 Oct 2023 05:27:54 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 314b26d3adca98a761c7e4d9922ebb206ff024a0 |
@@ -0,0 +1,16 @@ | |||
import { useEffect } from 'react' | |||
|
|||
export function usePreventScroll(element: HTMLElement | null, isOpen: boolean) { |
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.
paddingRight がどこから来てるのか調べていたらここにあたって ios 用の分岐が必要そうだったが、実機で確認したところ問題なかった
if (isOpen && element) { | ||
const defaultPaddingRight = element.style.paddingRight | ||
const defaultOverflow = element.style.overflow | ||
element.style.paddingRight = document.documentElement.style.paddingRight |
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.
document.documentElement.style.paddingRight
からの取得だと Overaly
コンポーネントの usePreventScroll
経由の取得になっていて DOM を global state として扱っているのがバグる危険性を秘めていそうだなと思いました。
元実装がシンプルなものだったのでそのまま書くというのはどうでしょうか?
setStyle(document.documentElement, 'paddingRight', `${window.innerWidth - document.documentElement.clientWidth}px`),
やったこと
動作確認
Storybookを確認してください。