diff --git a/packages/app-mobile/components/ActionButton.tsx b/packages/app-mobile/components/ActionButton.tsx index e8bcc2d79..0fdb0161c 100644 --- a/packages/app-mobile/components/ActionButton.tsx +++ b/packages/app-mobile/components/ActionButton.tsx @@ -1,10 +1,12 @@ const React = require('react'); import { useState, useCallback, useMemo } from 'react'; - -const Icon = require('react-native-vector-icons/Ionicons').default; import { FAB, Portal } from 'react-native-paper'; import { _ } from '@joplin/lib/locale'; +import { Dispatch } from 'redux'; +const Icon = require('react-native-vector-icons/Ionicons').default; +// eslint-disable-next-line no-undef -- Don't know why it says React is undefined when it's defined above +type FABGroupProps = React.ComponentProps; type OnButtonPress = ()=> void; interface ButtonSpec { @@ -19,6 +21,7 @@ interface ActionButtonProps { // If not given, an "add" button will be used. mainButton?: ButtonSpec; + dispatch: Dispatch; } const defaultOnPress = () => {}; @@ -36,10 +39,12 @@ const useIcon = (iconName: string) => { const ActionButton = (props: ActionButtonProps) => { const [open, setOpen] = useState(false); - const onMenuToggled = useCallback( - (state: { open: boolean }) => setOpen(state.open) - , [setOpen]); - + const onMenuToggled: FABGroupProps['onStateChange'] = useCallback(state => { + props.dispatch({ + type: 'SIDE_MENU_CLOSE', + }); + setOpen(state.open); + }, [setOpen, props.dispatch]); const actions = useMemo(() => (props.buttons ?? []).map(button => { return { diff --git a/packages/app-mobile/components/NoteEditor/SearchPanel.tsx b/packages/app-mobile/components/NoteEditor/SearchPanel.tsx index e912da924..8f665b629 100644 --- a/packages/app-mobile/components/NoteEditor/SearchPanel.tsx +++ b/packages/app-mobile/components/NoteEditor/SearchPanel.tsx @@ -40,9 +40,7 @@ interface ActionButtonProps { onPress: Callback; } -const ActionButton = ( - props: ActionButtonProps, -) => { +const ActionButton = (props: ActionButtonProps) => { return ( ; + return ; }; // Save button is not really needed anymore with the improved save logic diff --git a/packages/app-mobile/components/screens/Notes.tsx b/packages/app-mobile/components/screens/Notes.tsx index 2b7c16628..db09a474b 100644 --- a/packages/app-mobile/components/screens/Notes.tsx +++ b/packages/app-mobile/components/screens/Notes.tsx @@ -265,7 +265,7 @@ class NotesScreenComponent extends BaseScreenComponent { color: '#9b59b6', icon: 'document', }); - return ; + return ; } return null; };