fix: chips not hiding when clicking cancel

This commit is contained in:
Antonella Sgarlatta
2021-03-23 11:33:23 -03:00
parent 9945204bd5
commit aeb449c41e
2 changed files with 20 additions and 2 deletions

View File

@@ -222,7 +222,10 @@ export const NoteList = (props: Props) => {
<AndroidSearchBar
ref={androidSearchBarInputRef}
onChangeText={onChangeSearchText}
onCancel={props.onSearchCancel}
onCancel={() => {
props.onSearchCancel();
onSearchBlur();
}}
onDelete={props.onSearchCancel}
onFocus={onSearchFocus}
onBlur={onSearchBlur}

View File

@@ -95,6 +95,10 @@ export const Notes = React.memo(
const [includeTrashedNotes, setIncludeTrashedNotes] = useState<boolean>(
true
);
const [
protectedTogglingStarted,
setProtectedTogglingStarted,
] = useState<boolean>(false);
const [shouldFocusSearch, setShouldFocusSearch] = useState<boolean>(false);
// Ref
@@ -179,6 +183,17 @@ export const Notes = React.memo(
[application, navigation, openNote]
);
useEffect(() => {
const removeBlurScreenListener = navigation.addListener('blur', () => {
if (protectedTogglingStarted) {
setProtectedTogglingStarted(false);
setShouldFocusSearch(true);
}
});
return removeBlurScreenListener;
}, [navigation, protectedTogglingStarted]);
useEffect(() => {
let mounted = true;
const removeEditorObserver = application?.editorGroup.addChangeObserver(
@@ -264,7 +279,7 @@ export const Notes = React.memo(
);
const toggleIncludeProtected = useCallback(async () => {
setShouldFocusSearch(true);
setProtectedTogglingStarted(true);
const includeProtected = !includeProtectedNoteText;
const allowToggling = includeProtected