@openpeepshq/rn-components 0.12.4 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,166 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Image, Linking, Pressable, View } from 'react-native';
3
+ import { useTranslation } from 'react-i18next';
4
+ import type { PostDataUnion, PublicPost } from '@openpeepshq/common/types';
5
+ import {
6
+ formatEventWhen,
7
+ postEditVersionKind,
8
+ postEditVersionTitle,
9
+ postEditVersions,
10
+ type PostVersionOrder,
11
+ } from '@openpeepshq/common/lib';
12
+ import { BaseSheet } from '../../../custom/modals/common/index';
13
+ import { UpdatingDate } from '../../../custom/date/updating-date';
14
+ import { OpenpeepsMarkdown } from '../../../markdown';
15
+ import { ThemedText } from '../../../ui/themed-text';
16
+ import { Button } from '../../../ui/button';
17
+ import { useControlledSheet } from '../../../../hooks/use-controlled-sheet';
18
+
19
+ export interface PostEditHistoryModalProps {
20
+ post: PublicPost;
21
+ open: boolean;
22
+ onClose: () => void;
23
+ }
24
+
25
+ const VersionBody = ({
26
+ post,
27
+ data,
28
+ }: {
29
+ post: PublicPost;
30
+ data: PostDataUnion;
31
+ }) => {
32
+ const { t } = useTranslation();
33
+ const title = postEditVersionTitle(data);
34
+ const image = 'image' in data ? data.image : undefined;
35
+
36
+ return (
37
+ <View className="gap-2">
38
+ {image ? (
39
+ <Image
40
+ source={{ uri: image }}
41
+ accessibilityLabel={title ?? ''}
42
+ className="h-40 w-full rounded-md"
43
+ resizeMode="cover"
44
+ />
45
+ ) : null}
46
+ {title ? (
47
+ <ThemedText className="text-base font-semibold">{title}</ThemedText>
48
+ ) : null}
49
+ {data.type === 'event' ? (
50
+ <ThemedText className="text-sm text-muted-foreground">
51
+ {formatEventWhen(data.start, {
52
+ end: data.end,
53
+ timeZone: data.timeZone,
54
+ allDay: data.wholeDay,
55
+ })}
56
+ </ThemedText>
57
+ ) : null}
58
+ {data.content ? (
59
+ <OpenpeepsMarkdown source={data.content} mentions={post.mentions} />
60
+ ) : null}
61
+ {data.type === 'question'
62
+ ? data.options.map((option, index) => (
63
+ <ThemedText key={`${option.content}-${index}`} className="text-sm">
64
+ {`• ${option.content}`}
65
+ </ThemedText>
66
+ ))
67
+ : null}
68
+ {data.type === 'resource' && data.url ? (
69
+ <Pressable onPress={() => void Linking.openURL(data.url!)}>
70
+ <ThemedText className="text-sm text-primary">{data.url}</ThemedText>
71
+ </Pressable>
72
+ ) : null}
73
+ {/* Entry snapshots keep only attachment metadata (no binary), so the
74
+ placeholder covers removed attachments. Media referenced inline in the
75
+ note/event/event-agenda content is not snapshotted either and renders
76
+ as plain markdown text in a version. */}
77
+ {data.attachments?.length ? (
78
+ <View className="rounded-md border border-dashed border-border p-2">
79
+ <ThemedText className="text-xs text-muted-foreground">
80
+ {t('posts.editHistory.mediaUnavailable', {
81
+ defaultValue: 'Media from this version is no longer available',
82
+ })}
83
+ </ThemedText>
84
+ </View>
85
+ ) : null}
86
+ </View>
87
+ );
88
+ };
89
+
90
+ export const PostEditHistoryModal = ({
91
+ post,
92
+ open,
93
+ onClose,
94
+ }: PostEditHistoryModalProps) => {
95
+ const { t } = useTranslation();
96
+ const ref = useControlledSheet(open);
97
+ const [order, setOrder] = useState<PostVersionOrder>('newest');
98
+
99
+ useEffect(() => {
100
+ if (open) setOrder('newest');
101
+ }, [open]);
102
+
103
+ const versions = postEditVersions(post.entries, order);
104
+ const kindLabel = {
105
+ original: t('posts.editHistory.original', { defaultValue: 'Original' }),
106
+ edit: t('posts.editHistory.edit', { defaultValue: 'Edit' }),
107
+ current: t('posts.editHistory.current', { defaultValue: 'Current' }),
108
+ };
109
+
110
+ return (
111
+ <BaseSheet ref={ref} snapPoints={['80%']} scrollable onDismiss={onClose}>
112
+ <View className="gap-3 px-4 pb-3">
113
+ <ThemedText className="text-center text-xl font-semibold">
114
+ {t('posts.editHistory.title')}
115
+ </ThemedText>
116
+ <Button
117
+ variant="outline"
118
+ size="sm"
119
+ className="self-start"
120
+ onPress={() =>
121
+ setOrder((current) => (current === 'oldest' ? 'newest' : 'oldest'))
122
+ }
123
+ >
124
+ <ThemedText>
125
+ {order === 'oldest'
126
+ ? t('posts.editHistory.newestFirst')
127
+ : t('posts.editHistory.oldestFirst')}
128
+ </ThemedText>
129
+ </Button>
130
+ <View
131
+ accessibilityLabel={t('posts.editHistory.title', {
132
+ defaultValue: 'Edit history',
133
+ })}
134
+ accessibilityRole="list"
135
+ className="gap-3"
136
+ >
137
+ {versions.map((version) => (
138
+ <View
139
+ key={version.id}
140
+ className="gap-2 rounded-md border border-border p-3"
141
+ >
142
+ <View className="flex-row flex-wrap items-center gap-2">
143
+ <ThemedText className="text-xs font-medium">
144
+ {kindLabel[postEditVersionKind(version)]}
145
+ </ThemedText>
146
+ <UpdatingDate
147
+ date={version.createdAt}
148
+ className="text-xs text-muted-foreground"
149
+ />
150
+ {version.profile?.handle ? (
151
+ <ThemedText className="text-xs text-muted-foreground">
152
+ {t('posts.editHistory.editedBy', {
153
+ defaultValue: 'by @{{handle}}',
154
+ handle: version.profile.handle,
155
+ })}
156
+ </ThemedText>
157
+ ) : null}
158
+ </View>
159
+ <VersionBody post={post} data={version.data} />
160
+ </View>
161
+ ))}
162
+ </View>
163
+ </View>
164
+ </BaseSheet>
165
+ );
166
+ };
@@ -2,5 +2,6 @@ export * from './CancelEventModal';
2
2
  export * from './DeleteEventModal';
3
3
  export * from './DeletePostModal';
4
4
  export * from './PostOptionsSheet';
5
+ export * from './PostEditHistoryModal';
5
6
  export * from './ReactionsModal';
6
7
  export * from './RepostModal';
@@ -14,7 +14,11 @@ import {
14
14
  normalizeResourceTags,
15
15
  resourceFormIssues,
16
16
  } from '@openpeepshq/common/lib';
17
- import { applyAudienceSetting, useCurrentProfile } from '@openpeepshq/react';
17
+ import {
18
+ applyAudienceSetting,
19
+ useCurrentProfile,
20
+ useResourceLibrary,
21
+ } from '@openpeepshq/react';
18
22
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
19
23
  import {
20
24
  AudioPickerSheet,
@@ -28,6 +32,7 @@ import { ThemedText } from '../../ui/themed-text';
28
32
  import { ComposeAttachments } from './ComposeAttachments';
29
33
  import { OpenpeepsMarkdownInput } from './OpenpeepsMarkdownInput';
30
34
  import { VisibilitySelector } from './VisibilitySelector';
35
+ import { CategoryPathPicker } from '../../resources/CategoryPathPicker';
31
36
 
32
37
  export interface ResourceFormProps {
33
38
  postData: PostCreationData;
@@ -47,6 +52,10 @@ export const ResourceForm = ({
47
52
  const me = useCurrentProfile();
48
53
  const resource = postData.data as ResourcePost;
49
54
  const [tagDraft, setTagDraft] = useState('');
55
+ const library = useResourceLibrary(
56
+ postData.groupId ?? undefined,
57
+ !postData.groupId
58
+ );
50
59
  const imageRef = useRef<BottomSheetModal>(null);
51
60
  const videoRef = useRef<BottomSheetModal>(null);
52
61
  const audioRef = useRef<BottomSheetModal>(null);
@@ -211,7 +220,8 @@ export const ResourceForm = ({
211
220
  </>
212
221
  ) : (
213
222
  <>
214
- {/* Only galleries take more than one file; other kinds pick once. */}
223
+ {/* Every image pick is single-file so the crop/alt-text dialog
224
+ shows for every image; galleries stay open for further picks (#1789). */}
215
225
  {resource.resourceKind === 'gallery' ||
216
226
  (resource.attachments ?? []).length === 0 ? (
217
227
  <Pressable
@@ -297,19 +307,10 @@ export const ResourceForm = ({
297
307
  defaultValue: 'Place in the library',
298
308
  })}
299
309
  </ThemedText>
300
- <Input
301
- value={(resource.categoryPath ?? []).join(' / ')}
302
- onChangeText={(value) =>
303
- patchResource({
304
- categoryPath: value
305
- .split('/')
306
- .map((segment) => segment.trim())
307
- .filter(Boolean),
308
- })
309
- }
310
- placeholder={t('resources.form.addLevel', {
311
- defaultValue: 'Add a folder',
312
- })}
310
+ <CategoryPathPicker
311
+ path={resource.categoryPath ?? []}
312
+ tree={library.tree}
313
+ onChange={(categoryPath: string[]) => patchResource({ categoryPath })}
313
314
  />
314
315
 
315
316
  <ThemedText className="text-sm font-medium">
@@ -347,7 +348,6 @@ export const ResourceForm = ({
347
348
  ) : null}
348
349
  </View>
349
350
  <ImagePickerSheet ref={imageRef} onSelect={addAttachments} />
350
- {/* Only galleries take more than one file; other kinds pick one. */}
351
351
  <VideoPickerSheet
352
352
  ref={videoRef}
353
353
  multiple={false}
@@ -230,7 +230,9 @@ export const VisibilitySheet = forwardRef<
230
230
  <ProfileSelector
231
231
  ref={audiencePickerModalRef}
232
232
  onSelect={setSelectedProfiles}
233
- title="Select Audience"
233
+ title={t('posts.form.audienceTitle', {
234
+ defaultValue: 'Who can see this?',
235
+ })}
234
236
  initialProfiles={selectedAudience.audience ?? []}
235
237
  editMode
236
238
  />
@@ -52,20 +52,56 @@ jest.mock('react-i18next', () => ({
52
52
  }));
53
53
 
54
54
  // --- openpeeps context + server info --------------------------------------
55
- jest.mock('@openpeepshq/react', () => ({
56
- useOpenpeeps: () => ({
57
- currentProfile: mockProfile,
58
- openpeepsApi: {
59
- rsvpManageAction: () => ({}),
60
- useJamAttendance: () => ({ isSuccess: false, data: [] }),
61
- useJamState: () => ({ data: mockJamState }),
62
- usePostRecordings: () => ({ data: [] }),
63
- usePostContext: () => ({ data: undefined }),
55
+ // `useEventDisplayTimeZone` is stubbed as a thin pass-through over these two
56
+ // mocked values, so the RN suite exercises the same contract as the real hook:
57
+ // profile settings -> community default -> event zone; no device-zone tier.
58
+ let mockProfileSettingsTimeZone: string | undefined = undefined;
59
+ const setProfileSettingsTimeZone = (timeZone?: string) => {
60
+ mockProfileSettingsTimeZone = timeZone;
61
+ };
62
+ let mockCommunityDefaultTimeZone: string | undefined = undefined;
63
+ const setCommunityDefaultTimeZone = (timeZone?: string) => {
64
+ mockCommunityDefaultTimeZone = timeZone;
65
+ };
66
+ jest.mock('@openpeepshq/react', () => {
67
+ return {
68
+ useOpenpeeps: () => ({
69
+ currentProfile: mockProfile,
70
+ openpeepsApi: {
71
+ rsvpManageAction: () => ({}),
72
+ useJamAttendance: () => ({ isSuccess: false, data: [] }),
73
+ useJamState: () => ({ data: mockJamState }),
74
+ usePostRecordings: () => ({ data: [] }),
75
+ usePostContext: () => ({ data: undefined }),
76
+ },
77
+ client: mockClient,
78
+ }),
79
+ useServerInfo: mockUseServerInfo,
80
+ // Pass-through over the mocked tiers, gated by Intl's own IANA check —
81
+ // the ESM @openpeepshq/common dist cannot be required under the jest node
82
+ // env, so this mirrors eventDisplayTimeZone's isIanaTimeZone gate only.
83
+ useEventDisplayTimeZone: (eventTimeZone?: string | null) => {
84
+ const isIana = (tz?: string | null): tz is string => {
85
+ if (!tz) return false;
86
+ try {
87
+ new Intl.DateTimeFormat('en-US', { timeZone: tz });
88
+ return true;
89
+ } catch {
90
+ return false;
91
+ }
92
+ };
93
+ return (
94
+ (isIana(mockProfileSettingsTimeZone)
95
+ ? mockProfileSettingsTimeZone
96
+ : undefined) ??
97
+ (isIana(mockCommunityDefaultTimeZone)
98
+ ? mockCommunityDefaultTimeZone
99
+ : undefined) ??
100
+ (isIana(eventTimeZone) ? eventTimeZone : undefined)
101
+ );
64
102
  },
65
- client: mockClient,
66
- }),
67
- useServerInfo: mockUseServerInfo,
68
- }));
103
+ };
104
+ });
69
105
 
70
106
  // --- shared (pure) helpers -------------------------------------------------
71
107
  jest.mock('@openpeepshq/common', () => ({
@@ -76,8 +112,17 @@ jest.mock('@openpeepshq/common/lib', () => ({
76
112
  canAccessJamRecordings: () => false,
77
113
  canModerateJam: () => false,
78
114
  canViewJamAttendees: () => false,
79
- effectiveEventTimes: () => ({}),
80
- eventTimeZoneOptions: () => ({ label: 'UTC' }),
115
+ effectiveEventTimes: (event?: { start?: string }) =>
116
+ event?.start ? { start: event.start } : {},
117
+ eventTimeZoneOptions: (timeZone?: string | null) => {
118
+ if (typeof timeZone !== 'string') return {};
119
+ try {
120
+ new Intl.DateTimeFormat('en-US', { timeZone });
121
+ return { timeZone };
122
+ } catch {
123
+ return {};
124
+ }
125
+ },
81
126
  formatEventClockTime: () => '',
82
127
  formatEventRecurrence: () => '',
83
128
  listRsvpOccurrences: () => [],
@@ -308,6 +353,8 @@ function render(
308
353
  beforeEach(() => {
309
354
  mockJamState = undefined;
310
355
  mockProfile = { id: 'u-1', displayName: 'Att', handle: 'att' };
356
+ mockProfileSettingsTimeZone = undefined;
357
+ mockCommunityDefaultTimeZone = undefined;
311
358
  mockUseServerInfo.mockReset();
312
359
  mockUseServerInfo.mockReturnValue({ jams: { livekit: { enabled: true } } });
313
360
  });
@@ -466,3 +513,76 @@ describe('tappable Jam URL', () => {
466
513
  tree.unmount();
467
514
  });
468
515
  });
516
+
517
+ // Display time zone (issue #2129): FullEvent resolves the viewer's zone via
518
+ // useEventDisplayTimeZone (profile settings -> community default -> event
519
+ // zone) and appends the "in your time zone" suffix whenever the resolved zone
520
+ // is a resolvable zone that differs from the event's own zone.
521
+ describe('event display time zone', () => {
522
+ const timedPost = {
523
+ ...BASE_POST,
524
+ data: {
525
+ ...BASE_POST.data,
526
+ timeZone: 'America/New_York',
527
+ start: '2026-06-15T14:30:00Z',
528
+ },
529
+ };
530
+
531
+ test('12. profile settings time zone differing from the event zone -> suffix renders', () => {
532
+ setProfileSettingsTimeZone('Europe/Berlin');
533
+ const tree = render(timedPost);
534
+ const json = JSON.stringify(tree.toJSON());
535
+ expect(json).toContain('in your time zone');
536
+ expect(json).toContain('(Europe/Berlin)');
537
+ tree.unmount();
538
+ });
539
+
540
+ test('13. display zone matching the event zone -> no suffix', () => {
541
+ setProfileSettingsTimeZone('America/New_York');
542
+ const tree = render(timedPost);
543
+ const json = JSON.stringify(tree.toJSON());
544
+ expect(json).not.toContain('in your time zone');
545
+ tree.unmount();
546
+ });
547
+
548
+ test('14. no profile settings time zone -> falls back to event zone, no suffix', () => {
549
+ setProfileSettingsTimeZone(undefined);
550
+ const tree = render(timedPost);
551
+ const json = JSON.stringify(tree.toJSON());
552
+ expect(json).not.toContain('in your time zone');
553
+ tree.unmount();
554
+ });
555
+
556
+ test('15. community default time zone used when the profile has none -> suffix renders', () => {
557
+ setProfileSettingsTimeZone(undefined);
558
+ setCommunityDefaultTimeZone('Europe/Berlin');
559
+ const tree = render(timedPost);
560
+ const json = JSON.stringify(tree.toJSON());
561
+ expect(json).toContain('in your time zone');
562
+ expect(json).toContain('(Europe/Berlin)');
563
+ tree.unmount();
564
+ });
565
+
566
+ test('16. unresolvable zones -> no suffix and no zone label', () => {
567
+ setProfileSettingsTimeZone('Not/AZone');
568
+ const tree = render({
569
+ ...timedPost,
570
+ data: { ...timedPost.data, timeZone: undefined },
571
+ });
572
+ const json = JSON.stringify(tree.toJSON());
573
+ expect(json).not.toContain('in your time zone');
574
+ expect(json).not.toContain('Not/AZone');
575
+ tree.unmount();
576
+ });
577
+
578
+ test('17. invalid profile zone ignored, community default wins -> suffix renders', () => {
579
+ setProfileSettingsTimeZone('Not/AZone');
580
+ setCommunityDefaultTimeZone('Europe/Berlin');
581
+ const tree = render(timedPost);
582
+ const json = JSON.stringify(tree.toJSON());
583
+ expect(json).toContain('in your time zone');
584
+ expect(json).toContain('(Europe/Berlin)');
585
+ expect(json).not.toContain('Not/AZone');
586
+ tree.unmount();
587
+ });
588
+ });
@@ -68,6 +68,7 @@ import {
68
68
  import { ThemedView } from '../../../ui/themed-view';
69
69
  import { EventOccurrenceList } from '../../pieces/EventOccurrenceList';
70
70
  import { EventRsvpList } from '../../pieces/EventRsvpList';
71
+ import { useEventDisplayTimeZone } from '@openpeepshq/react';
71
72
 
72
73
  import {
73
74
  EventMenu,
@@ -128,7 +129,8 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
128
129
  }
129
130
  };
130
131
  const times = effectiveEventTimes(event, occurrence);
131
- const tz = eventTimeZoneOptions(event?.timeZone);
132
+ const displayTz = useEventDisplayTimeZone(event?.timeZone);
133
+ const tz = eventTimeZoneOptions(displayTz);
132
134
  const recurrenceLabel = event?.recurrence
133
135
  ? formatEventRecurrence(event.recurrence, t, event.start)
134
136
  : '';
@@ -310,16 +312,21 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
310
312
  </ThemedText>
311
313
  <ThemedText className="text-muted-foreground mt-2">
312
314
  {formatEventClockTime(times.start, {
313
- timeZone: event?.timeZone,
315
+ timeZone: displayTz,
314
316
  locale: 'en-US',
315
317
  })}
316
318
  {times.end
317
319
  ? ` - ${formatEventClockTime(times.end, {
318
- timeZone: event?.timeZone,
320
+ timeZone: displayTz,
319
321
  locale: 'en-US',
320
322
  })}`
321
323
  : ''}
322
324
  {tz.timeZone ? ` (${tz.timeZone})` : ''}
325
+ {displayTz && displayTz !== event?.timeZone
326
+ ? ` — ${t('events.inYourTimeZone', {
327
+ defaultValue: 'in your time zone',
328
+ })}`
329
+ : ''}
323
330
  </ThemedText>
324
331
  </View>
325
332
  </View>
@@ -393,6 +400,7 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
393
400
  occurrences={upcomingOccurrences}
394
401
  currentOccurrenceId={occurrence}
395
402
  recurrenceLabel={recurrenceLabel}
403
+ timeZone={displayTz}
396
404
  />
397
405
  ) : null}
398
406
  <EventRsvpButton post={post as PublicPost} recurrenceId={occurrence} />
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Regression tests for the ProfileSelector sheet title (issue #1666).
3
+ *
4
+ * The sheet used to hard-code the English string "Add members", so every
5
+ * caller that omitted `title` (jam moderators, group members, event
6
+ * moderators) rendered untranslated copy, and the audience picker could be
7
+ * re-titled to a non-matching string. Web defaults to
8
+ * `profile.selector.title` ("Select profiles"); RN must match.
9
+ */
10
+
11
+ const React = require('react');
12
+ const ReactTestRenderer = require('react-test-renderer');
13
+
14
+ const mockT = (key: string) => MESSAGES[key] ?? key;
15
+
16
+ const MESSAGES: Record<string, string> = {
17
+ 'profile.selector.title': 'Select profiles',
18
+ 'profile.search.placeholder': 'Search profiles',
19
+ 'profile.search.noResults': 'No results found',
20
+ 'common.members.addSuccess': 'Added',
21
+ 'common.members.addError': 'Failed',
22
+ 'common.members.adding': 'Adding',
23
+ 'common.actions.add': 'Add',
24
+ };
25
+
26
+ jest.mock('react-native', () => ({
27
+ View: (props: { children?: unknown }) =>
28
+ React.createElement('View', null, props.children),
29
+ ScrollView: (props: { children?: unknown }) =>
30
+ React.createElement('ScrollView', null, props.children),
31
+ ActivityIndicator: () => null,
32
+ }));
33
+
34
+ jest.mock('react-i18next', () => ({
35
+ useTranslation: () => ({ t: mockT }),
36
+ }));
37
+
38
+ jest.mock('@openpeepshq/react', () => ({
39
+ useOpenpeeps: () => ({
40
+ openpeepsApi: {
41
+ // Stable array identity: the component's effect depends on `profiles`
42
+ // and a fresh literal each render would loop forever.
43
+ useProfiles: () => ({ data: PROFILES, isLoading: false }),
44
+ },
45
+ currentProfile: null,
46
+ }),
47
+ }));
48
+
49
+ const PROFILES: unknown[] = [];
50
+
51
+ jest.mock('../../lib/utils', () => ({
52
+ profileMatchesQuery: () => true,
53
+ }));
54
+
55
+ jest.mock('../icons/index', () => ({
56
+ CheckIcon: () => React.createElement('CheckIcon'),
57
+ SearchIcon: () => React.createElement('SearchIcon'),
58
+ }));
59
+
60
+ jest.mock('../ui/input', () => ({
61
+ Input: () => null,
62
+ }));
63
+
64
+ jest.mock('../ui/themed-text', () => ({
65
+ ThemedText: (props: Record<string, unknown>) =>
66
+ React.createElement('ThemedText', props, props.children),
67
+ }));
68
+
69
+ jest.mock('../custom/modals/common', () => ({
70
+ BaseSheet: (props: { children?: unknown }) =>
71
+ React.createElement('BaseSheet', null, props.children),
72
+ SheetFooter: () => null,
73
+ }));
74
+
75
+ jest.mock('react-native-toast-message', () => ({ show: jest.fn() }));
76
+
77
+ jest.mock('../../lib/bottom-sheet-ref', () => ({
78
+ bottomSheetClose: jest.fn(),
79
+ }));
80
+
81
+ jest.mock('./ProfileCard', () => ({
82
+ MiniProfileCard: () => null,
83
+ ProfileCard: () => null,
84
+ }));
85
+
86
+ import type { ProfilePickerSheetProps } from './ProfileSelector';
87
+ import { ProfileSelector } from './ProfileSelector';
88
+
89
+ const renderSelector = (props: Partial<ProfilePickerSheetProps> = {}) => {
90
+ let tree: ReturnType<typeof ReactTestRenderer.create>;
91
+ ReactTestRenderer.act(() => {
92
+ tree = ReactTestRenderer.create(
93
+ React.createElement(ProfileSelector, props as ProfilePickerSheetProps)
94
+ );
95
+ });
96
+ return tree;
97
+ };
98
+
99
+ const titleText = (tree: ReturnType<typeof ReactTestRenderer.create>) =>
100
+ tree.root
101
+ .findAllByType('ThemedText')
102
+ .map((node: { props: { children?: unknown } }) => node.props.children)
103
+ .find((child) => typeof child === 'string');
104
+
105
+ describe('ProfileSelector sheet title (issue #1666)', () => {
106
+ it('falls back to the localized profile.selector.title when no title is passed', () => {
107
+ const tree = renderSelector();
108
+ expect(titleText(tree)).toBe('Select profiles');
109
+ });
110
+
111
+ it('uses an explicit title when the caller passes one', () => {
112
+ const tree = renderSelector({ title: 'Add members to Test Group' });
113
+ expect(titleText(tree)).toBe('Add members to Test Group');
114
+ });
115
+ });
@@ -33,7 +33,7 @@ export const ProfileSelector = forwardRef<
33
33
  {
34
34
  onSelect,
35
35
  asynOnSelect,
36
- title = 'Add members',
36
+ title,
37
37
  profilesToExclude,
38
38
  selectType = 'sync',
39
39
  initialProfiles,
@@ -131,7 +131,7 @@ export const ProfileSelector = forwardRef<
131
131
 
132
132
  <View className="w-full">
133
133
  <ThemedText className="text-center text-xl font-semibold mb-6">
134
- {title}
134
+ {title ?? t('profile.selector.title')}
135
135
  </ThemedText>
136
136
  <View className="flex-row items-center mb-4 w-full">
137
137
  <View className="rounded-l-md bg-surface p-3">