-
Notifications
You must be signed in to change notification settings - Fork 11k
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 ocasionally not focusing properly making input unusable #34853
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
--- | ||
|
||
fixes an issue where opening a modal for the first times renders it's inputs unusable | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import { useLayout, useSetting, useCurrentModal, useRoute, useCurrentRoutePath } from '@rocket.chat/ui-contexts'; | ||
import type { ReactElement, ReactNode } from 'react'; | ||
import { useEffect, useRef } from 'react'; | ||
import { useEffect, useRef, version } from 'react'; | ||
|
||
import AccessibilityShortcut from './AccessibilityShortcut'; | ||
import { MainLayoutStyleTags } from './MainLayoutStyleTags'; | ||
import Sidebar from '../../../sidebar'; | ||
|
||
const inertBooleanSupported = Number(version.split('.')[0]) >= 19; | ||
|
||
/** | ||
* Before version 19, react JSX treats empty string "" as truthy for inert prop. | ||
* @see {@link https://stackoverflow.com/questions/72720469} | ||
* */ | ||
const isInert = inertBooleanSupported ? (x: boolean) => x : (x: boolean) => (x ? '' : undefined); | ||
|
||
Comment on lines
+10
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this will need to be replicated to LayoutSidebarV2. It might be a good idea to have this as an util and use it in both files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot that guy 😬 |
||
const LayoutWithSidebar = ({ children }: { children: ReactNode }): ReactElement => { | ||
const { isEmbedded: embeddedLayout } = useLayout(); | ||
|
||
|
@@ -44,7 +52,10 @@ const LayoutWithSidebar = ({ children }: { children: ReactNode }): ReactElement | |
bg='surface-light' | ||
id='rocket-chat' | ||
className={[embeddedLayout ? 'embedded-view' : undefined, 'menu-nav'].filter(Boolean).join(' ')} | ||
aria-hidden={Boolean(modal)} | ||
// @types/react does not recognize the "inert" prop as of now | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
inert={isInert(Boolean(modal))} | ||
> | ||
<AccessibilityShortcut /> | ||
<MainLayoutStyleTags /> | ||
|
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.