Skip to content

Commit a7cf4bd

Browse files
authored
hide popup on click user/team lookup (#28461)
* hide popup on click * watch nav events and close modals on mobile * handle more admins
1 parent 552271a commit a7cf4bd

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

shared/common-adapters/floating-menu/index.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
// For stories, all popups using FloatingMenu will need to have a PropProvider
2-
// decorator added to the story. This is because FloatingMenus are rendered
3-
// into a GatewayDest component in a storybook context. GatewayDest is only
4-
// rendered if a PropProvider decorated is used. This is done so that connected
5-
// components inside of a popup have access to the mocked out Provider component
6-
71
import * as React from 'react'
82
import Overlay from '../overlay'
93
import {Box2} from '@/common-adapters/box'
@@ -21,6 +15,7 @@ import {
2115
import {useSafeAreaInsets} from '@/common-adapters/safe-area-view'
2216
import {FloatingModalContext} from './context'
2317
import {FullWindowOverlay} from 'react-native-screens'
18+
import {useNavigation} from '@react-navigation/native'
2419

2520
const Kb = {
2621
Box2,
@@ -67,12 +62,22 @@ const FullWindow = ({children}: {children?: React.ReactNode}): React.ReactNode =
6762
const defaultSnapPoints = ['75%']
6863

6964
const FloatingMenu = React.memo(function FloatingMenu(props: Props) {
70-
const {snapPoints, items, visible} = props
65+
const {snapPoints, items, visible, onHidden} = props
7166
const isModal = React.useContext(FloatingModalContext)
7267
const shownRef = React.useRef(false)
7368

7469
const bottomRef = React.useRef<BottomSheetModal | null>(null)
7570

71+
const navigation = useNavigation()
72+
73+
React.useEffect(() => {
74+
const unsub = navigation.addListener('state', () => {
75+
bottomRef.current?.forceClose()
76+
onHidden()
77+
})
78+
return unsub
79+
}, [bottomRef, navigation, onHidden])
80+
7681
React.useEffect(() => {
7782
return () => {
7883
bottomRef.current?.forceClose()
@@ -138,7 +143,7 @@ const FloatingMenu = React.memo(function FloatingMenu(props: Props) {
138143
<Kb.Overlay
139144
position={props.position}
140145
positionFallbacks={props.positionFallbacks}
141-
onHidden={props.onHidden}
146+
onHidden={onHidden}
142147
visible={props.visible}
143148
attachTo={props.attachTo}
144149
remeasureHint={props.remeasureHint}

shared/common-adapters/markdown/maybe-mention/unknown.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@ type Props = {
5050
}
5151

5252
const UnknownMention = (props: Props) => {
53+
const {onResolve: _onResolve} = props
5354
const [showPopup, setShowPopup] = React.useState(false)
5455
const mentionRef = React.useRef<MeasureRef | null>(null)
5556

56-
const handleMouseOver = () => setShowPopup(true)
57-
const handleMouseLeave = () => setShowPopup(false)
57+
const handleMouseOver = React.useCallback(() => setShowPopup(true), [])
58+
const handleMouseLeave = React.useCallback(() => setShowPopup(false), [])
59+
60+
const onResolve = React.useCallback(() => {
61+
_onResolve()
62+
handleMouseLeave()
63+
}, [_onResolve, handleMouseLeave])
5864

5965
let text = `@${props.name}`
6066
if (props.channel.length > 0) {
@@ -78,7 +84,7 @@ const UnknownMention = (props: Props) => {
7884
<UnknownMentionPopup
7985
attachTo={mentionRef}
8086
onHidden={handleMouseLeave}
81-
onResolve={props.onResolve}
87+
onResolve={onResolve}
8288
text={text}
8389
visible={showPopup}
8490
/>

shared/profile/user/teams/teaminfo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const TeamInfo = (props: Props) => {
125125
onUsernameClicked="profile"
126126
usernames={props.publicAdmins}
127127
containerStyle={styles.publicAdmins}
128+
lineClamp={5}
128129
/>
129130
}
130131
</Kb.Text>

0 commit comments

Comments
 (0)