2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Shadcn/uiのdialogをcloseしたときにbodyにpointer-event:none;が残ってしまう対処法

Last updated at Posted at 2025-02-03

結論

DialogContentにonCloseAutoFocusを追加して、明示的にスタイルを削除する

...
    <DialogContent
        onClick={(e) => e.stopPropagation()}
        onCloseAutoFocus={(event) => {
            event.preventDefault();
            document.body.style.pointerEvents = '';
        }}
        className="focus:outline-none"
    >
...

参考になれば幸いです。(もっと早くGitHubのissuesで検索すればよかった・・・)

参考サイト

Shadcn/ui Dialog
解決法があったIssues
Radix UIのDialogページ

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?