-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added desktop file and updated focus manager
Signed-off-by: Ayaz Alavi <ayaz.alavi@gmail.com>
- Loading branch information
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '../../../ONYXKEYS'; | ||
import * as Browser from '../../Browser'; | ||
import ReportActionComposeFocusManager from '../../ReportActionComposeFocusManager'; | ||
|
||
function inputFocusChange(focus: boolean) { | ||
Onyx.set(ONYXKEYS.INPUT_FOCUSED, focus); | ||
} | ||
|
||
let refSave: HTMLElement | undefined; | ||
function composerFocusKeepFocusOn(ref: HTMLElement, isFocused: boolean, modal: { willAlertModalBecomeVisible: boolean; isVisible: boolean }, onyxFocused: boolean) { | ||
if (isFocused && !onyxFocused) { | ||
inputFocusChange(true); | ||
ref.focus(); | ||
} | ||
if (isFocused) { | ||
refSave = ref; | ||
} | ||
if (!isFocused && !onyxFocused && !modal.willAlertModalBecomeVisible && !modal.isVisible && refSave) { | ||
if (!ReportActionComposeFocusManager.isFocused()) { | ||
refSave.focus(); | ||
} else { | ||
refSave = undefined; | ||
} | ||
} | ||
} | ||
|
||
const callback = (method: () => void) => method(); | ||
|
||
export {composerFocusKeepFocusOn, inputFocusChange, callback}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters