Skip to content

Commit a781902

Browse files
committed
fix(Toast): fix long words overflowing toast container
1 parent bae7179 commit a781902

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/@react-spectrum/s2/src/Toast.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ const toastContent = style({
296296
alignItems: 'baseline',
297297
gridArea: 'content',
298298
cursor: 'default',
299-
width: 'fit'
299+
width: 'fit',
300+
overflowWrap: 'break-word',
301+
wordBreak: 'break-word',
302+
minWidth: 0
300303
});
301304

302305
const controls = style({

packages/@react-spectrum/s2/stories/Toast.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ export const Example: Story = {
7979
variant="accent">
8080
Show Long Toast
8181
</Button>
82+
<Button
83+
onPress={() => UNSTABLE_ToastQueue.info('LoremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquaUtenimaminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipeacommodoconsequat.', {...args, onClose: action('onClose')})}
84+
variant="accent">
85+
Show Long Word Toast
86+
</Button>
8287
</ButtonGroup>
8388
</>
8489
)

packages/@react-spectrum/s2/style/spectrum-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ export const style = createTheme({
828828
hyphens: ['none', 'manual', 'auto'] as const,
829829
whiteSpace: ['normal', 'nowrap', 'pre', 'pre-line', 'pre-wrap', 'break-spaces'] as const,
830830
textWrap: ['wrap', 'nowrap', 'balance', 'pretty'] as const,
831-
wordBreak: ['normal', 'break-all', 'keep-all'] as const,
831+
wordBreak: ['normal', 'break-all', 'keep-all', 'break-word'] as const,
832832
overflowWrap: ['normal', 'anywhere', 'break-word'] as const,
833833
boxDecorationBreak: ['slice', 'clone'] as const,
834834

0 commit comments

Comments
 (0)