Skip to content

Commit 83b200c

Browse files
refactor(mosaic): patch suggestions on accept and fold one-rule styles (#10629)
1 parent d0f65d7 commit 83b200c

5 files changed

Lines changed: 14 additions & 19 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

‎packages/mosaic/src/features/reverification/reverification.styles.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const stackedFooter = '@container card (max-width: 20rem)' as const;
66
const half = `calc(50% - ${space['1']})`;
77

88
export const styles = stylex.create({
9+
helpText: {
10+
textAlign: 'center',
11+
},
912
pending: {
1013
paddingBlock: space['12'],
1114
alignItems: 'center',

‎packages/mosaic/src/features/reverification/steps/reverification-method-picker.tsx‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useMergeRefs } from '@floating-ui/react';
2-
import * as stylex from '@stylexjs/stylex';
32
import type { Ref } from 'react';
43

54
import { Button } from '../../../components/button';
@@ -12,12 +11,7 @@ import { Spinner } from '../../../components/spinner';
1211
import { Text } from '../../../components/text';
1312
import { ChevronRight } from '../../../icons/glyphs/chevron-right';
1413
import { rtl } from '../../../styles/rtl.styles';
15-
16-
const styles = stylex.create({
17-
helpText: {
18-
textAlign: 'center',
19-
},
20-
});
14+
import { styles } from '../reverification.styles';
2115

2216
export interface ReverificationMethod {
2317
id: string;

‎packages/mosaic/src/features/switcher/switcher.model.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,15 @@ export function useSwitcherModel(options?: SwitcherModelOptions, modals?: Switch
401401
onAcceptSuggestion: async suggestionId => {
402402
const suggestion = suggestionData.find(s => s.id === suggestionId);
403403
try {
404-
await suggestion?.accept();
405-
} finally {
406-
// We always revalidate, a failed accept might be because of old state
404+
const accepted = await suggestion?.accept();
405+
if (accepted) {
406+
await userSuggestions.setData?.(pages => replaceInPages(pages ?? [], accepted));
407+
}
408+
} catch (error) {
409+
// A failed accept might be because of old state
407410
// Using allSettled since it never throws and we don't want failed revalidates to look like failed accepts
408411
await Promise.allSettled([userSuggestions.revalidate?.()]);
412+
throw error;
409413
}
410414
},
411415
onAcceptInvitation: async invitationId => {

‎packages/mosaic/src/utils/truncatable-label.tsx‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ import React from 'react';
44
import { reset } from '../styles/reset.styles';
55
import { truncationStyles } from '../styles/typography.styles';
66

7-
// The ellipsis comes from `truncationStyles.singleLine`; this releases the flex-item min-width
8-
// floor, without which the box never shrinks enough to clip.
9-
const styles = stylex.create({
10-
label: {
11-
minWidth: 0,
12-
},
13-
});
14-
157
// Wrap the text children so they have a box of their own to truncate against — a bare text
168
// child is laid out in an anonymous flex item that no selector can reach. A whole run of
179
// adjacent text shares one box, or `Delete {name}` would split into two flex items with the
@@ -28,7 +20,7 @@ export function withTruncatableLabel(children: React.ReactNode): React.ReactNode
2820
result.push(
2921
<span
3022
key={`label-${result.length}`}
31-
{...stylex.props(reset.base, truncationStyles.singleLine, styles.label)}
23+
{...stylex.props(reset.base, truncationStyles.singleLine)}
3224
>
3325
{run}
3426
</span>,

0 commit comments

Comments
 (0)