Skip to content

Commit 6f2d3da

Browse files
committed
WebLink: Forward text prop to ZulipText, fixing CustomProfileFields crash
This fixes a regression introduced in 72280dd, released in the v27.198 beta. The underlying ZulipText was throwing its error `text` or `children` should be non-nullish when the user navigated to a profile screen that tried to render a "link" type custom profile field, such as a GitHub link.
1 parent ff08de2 commit 6f2d3da

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/common/WebLink.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@ import { openLinkWithUserPreference } from '../utils/openLink';
77
import { BRAND_COLOR, createStyleSheet } from '../styles';
88
import { useGlobalSelector } from '../react-redux';
99
import { getGlobalSettings } from '../directSelectors';
10+
import type { BoundedDiff } from '../generics';
11+
12+
type ZulipTextProps = $Exact<React$ElementConfig<typeof ZulipText>>;
1013

1114
type Props = $ReadOnly<{|
12-
...$Exact<React$ElementConfig<typeof ZulipText>>,
15+
...BoundedDiff<
16+
ZulipTextProps,
17+
{|
18+
// Could accept `style`, just be sure to merge with web-link style.
19+
style: ZulipTextProps['style'],
20+
21+
onPress: ZulipTextProps['onPress'],
22+
|},
23+
>,
1324
url: URL,
1425
|}>;
1526

@@ -28,18 +39,17 @@ const componentStyles = createStyleSheet({
2839
* special formatting, you have to pass `inheritColor` to those.
2940
*/
3041
export default function WebLink(props: Props): React.Node {
31-
const { children } = props;
42+
const { url, ...zulipTextProps } = props;
3243

3344
const globalSettings = useGlobalSelector(getGlobalSettings);
3445

3546
return (
3647
<ZulipText
3748
style={componentStyles.link}
3849
onPress={() => {
39-
openLinkWithUserPreference(props.url.toString(), globalSettings);
50+
openLinkWithUserPreference(url.toString(), globalSettings);
4051
}}
41-
>
42-
{children}
43-
</ZulipText>
52+
{...zulipTextProps}
53+
/>
4454
);
4555
}

0 commit comments

Comments
 (0)