Workaround for editor updating file when not focused in Safari (#23023)

GitOrigin-RevId: da9341b2cadf4b073eb4062619a9fa7bcba17c6b
This commit is contained in:
Domagoj Kriskovic
2025-01-22 13:17:24 +01:00
committed by Copybot
parent 21e24b1ec3
commit 00a10dcbf6

View File

@@ -103,6 +103,18 @@ export default function FileViewHeader({ file }: FileViewHeaderProps) {
{refreshError && (
<FileViewRefreshError file={file} refreshError={refreshError} />
)}
{/* Workaround for Safari issue: https://github.com/overleaf/internal/issues/21363
* The editor behind a file view receives key events and updates the file even if Codemirror view is not focused.
* Changing the focus to a hidden textarea prevents this
*/}
<textarea
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus
aria-hidden="true"
tabIndex={-1}
style={{ position: 'absolute', left: '-9999px' }}
/>
</>
)
}