mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #10339 from overleaf/as-fix-switch-back
Fix bug in CM6 switch away survey where going back from Ace to CM6 will still show the survey GitOrigin-RevId: 5900fafb1a4a5fab7d949b1c70af31e19a764e6e
This commit is contained in:
parent
618d41f623
commit
1c529d5dcf
1 changed files with 15 additions and 11 deletions
|
@ -36,29 +36,33 @@ export default function CM6SwitchAwaySurvey() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newSourceEditor) {
|
if (!newSourceEditor && !richText) {
|
||||||
setState('enabled')
|
setState('enabled')
|
||||||
|
} else {
|
||||||
|
setState('disabled')
|
||||||
}
|
}
|
||||||
}, [newSourceEditor, richText])
|
}, [newSourceEditor, richText])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (state === 'enabled') {
|
const handleKeyDown = () => {
|
||||||
const handleKeyDown = () => {
|
const TIME_FOR_SURVEY_TO_APPEAR = 3000
|
||||||
const TIME_FOR_SURVEY_TO_APPEAR = 3000
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (state === 'enabled') {
|
||||||
setState('shown')
|
setState('shown')
|
||||||
customLocalStorage.setItem(
|
customLocalStorage.setItem(
|
||||||
'editor.has_seen_cm6_switch_away_survey',
|
'editor.has_seen_cm6_switch_away_survey',
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
}, TIME_FOR_SURVEY_TO_APPEAR)
|
}
|
||||||
}
|
}, TIME_FOR_SURVEY_TO_APPEAR)
|
||||||
|
|
||||||
// can't access the ace editor directly, so add the keydown event
|
|
||||||
// to window
|
|
||||||
window?.addEventListener('keydown', handleKeyDown, { once: true })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// can't access the ace editor directly, so add the keydown event
|
||||||
|
// to window
|
||||||
|
window?.addEventListener('keydown', handleKeyDown, { once: true })
|
||||||
|
|
||||||
|
return () => window?.removeEventListener('keydown', handleKeyDown)
|
||||||
}, [state])
|
}, [state])
|
||||||
|
|
||||||
const handleClose = useCallback(() => {
|
const handleClose = useCallback(() => {
|
||||||
|
|
Loading…
Reference in a new issue