Skip to content
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: can't open selects inside modals on firefox #643

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@monaco-editor/react": "4.6.0",
"@radix-ui/react-accordion": "1.2.0",
"@radix-ui/react-dialog": "1.1.1",
"@radix-ui/react-focus-scope": "1.1.0",
"@react-aria/utils": "3.23.0",
"@react-hooks-library/core": "0.6.0",
"@react-spring/web": "9.7.3",
Expand All @@ -55,11 +56,11 @@
"lodash-es": "4.17.21",
"moment": "2.29.4",
"react-animate-height": "3.2.3",
"react-aria": "3.31.1",
"react-aria": "3.34.3",
"react-embed": "3.7.0",
"react-markdown": "9.0.1",
"react-merge-refs": "2.1.1",
"react-stately": "3.29.1",
"react-stately": "3.32.2",
"react-use-measure": "2.1.1",
"rehype-raw": "7.0.0",
"remark-gfm": "4.0.0",
Expand Down
26 changes: 21 additions & 5 deletions src/components/ModalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import * as Dialog from '@radix-ui/react-dialog'
import { type ReactNode, forwardRef } from 'react'
import styled, { type CSSObject, useTheme } from 'styled-components'

import { FocusScope } from '@radix-ui/react-focus-scope'

import WrapWithIf from './WrapWithIf'

const ANIMATION_SPEED = '150ms'

export type ModalWrapperProps = {
Expand All @@ -30,12 +34,24 @@ function ModalWrapperRef(
onClick={(e) => e.stopPropagation()}
style={overlayStyles}
>
<ContentSC
ref={ref}
{...props}
<WrapWithIf
condition={// band-aid for firefox not letting our select component open inside a modal
// see https://github.com/radix-ui/primitives/issues/2544
navigator?.userAgent.toLowerCase().includes('firefox')}
wrapper={
<FocusScope
trapped={false}
loop
/>
}
>
{children}
</ContentSC>
<ContentSC
ref={ref}
{...props}
>
{children}
</ContentSC>
</WrapWithIf>
</OverlaySC>
</Dialog.Portal>
</Dialog.Root>
Expand Down
Loading
Loading