-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
AppBar title hides on translation change #7745
Comments
Thanks for the report. I'm not sure if the bug in in react-admin or in the demo itself, but there definitely is a bug. What's weird is that I can't reproduce the problem in the Simple Example codesandbox, by switching the language from the user menu (the title doesn't disappear). It may be a sign that the problem lies in the way the Configuration component in the demo handles the title. |
@fzaninotto ,I have a different issue with title, which might be related I have a custom route under admin. When I load open a browser directly to this page <CustomRoutes>
<Route
path='/test/*'
element={
<>
<Title title="test title"/>
<>Test page</>
</>
}
/>
</CustomRoutes> |
In my case, it appears that the following code in const container =
typeof document !== 'undefined'
? document.getElementById('react-admin-title')
: null;
if (!container) return null; |
I created a custom title component that addresses the bug that I see on fresh page load. Not sure if that fixes the bug on language change:
@fzaninotto , can we incorporate similar checks and delays in RA title? Thanks const SafeTitle = (props: TitleProps) => {
const [ready, setReady] = useSafeSetState(false)
const container = (document && document.getElementById('react-admin-title')) || null
useEffect(() => {
const tgt = (document && document.getElementById('react-admin-title')) || null
if (tgt) {
setReady(true)
return
}
const timer = setTimeout(() => {
setReady(true)
}, 500)
return () => {
clearTimeout(timer)
}
}, [setReady])
if (!ready && !container) return null
else return <Title {...props} />
} |
The main issue may be related to a React bug that was fixed in React 18, according to facebook/react#20141 Could you please report if the bug still exists with React 18? |
@fzaninotto : We're on React v18.2.0 and unfortunately still getting this weird bug. App bar titles disappear across the entire site without any clearly-identifiable cause. |
The issue seems still persists on latest react-admin 4.9.2 and react 18.2 |
Hi @fzaninotto @septentrion-730n , I believe this issue may not be related to the bug that you mentioned. I think the bug is trigger because
I think the fix for this issue could be always trying to pass the key together into the context, and let |
What you were expecting:
The page title, e.g. "configuration", is shown
What happened instead:
Title hides until a different, not language configuration, has been toggled
Steps to reproduce:
Go on the demo page, click on the profile badge and click on the link to the configuration page. Change the language.
Related code:
https://github.com/marmelab/react-admin/blob/master/examples/demo/src/layout/AppBar.tsx
Other information:
Seems like it's rendering before the language change has been applied, maybe?
Environment
The text was updated successfully, but these errors were encountered: