Skip to content

Commit 8bbca85

Browse files
Fix #39: Pressing back button closes filter modal
1 parent 9b77013 commit 8bbca85

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Frontend/components/Filter.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
StyleSheet,
1010
TouchableHighlight,
1111
TouchableOpacity,
12+
BackHandler,
1213
} from 'react-native';
1314
import {
1415
IconButton,
@@ -54,6 +55,17 @@ function Filter(props) {
5455

5556
const {axiosInstance} = useAuth();
5657

58+
const backAction = React.useCallback(() => {
59+
Animated.timing(springAnim, {
60+
toValue: height + 100,
61+
duration: 256,
62+
useNativeDriver: true,
63+
}).start(() => {
64+
close();
65+
});
66+
return true;
67+
}, [close]);
68+
5769
React.useEffect(() => {
5870
const slideIn = () => {
5971
Animated.spring(springAnim, {
@@ -79,6 +91,13 @@ function Filter(props) {
7991
getSkills();
8092
}, []);
8193

94+
React.useEffect(() => {
95+
BackHandler.addEventListener('hardwareBackPress', backAction);
96+
97+
return () =>
98+
BackHandler.removeEventListener('hardwareBackPress', backAction);
99+
}, []);
100+
82101
const handleClose = () => {
83102
Animated.timing(springAnim, {
84103
toValue: height + 100,

0 commit comments

Comments
 (0)