diff --git a/packages/@react-spectrum/s2/src/Toast.tsx b/packages/@react-spectrum/s2/src/Toast.tsx index ff945fd7ce0..5323c91f745 100644 --- a/packages/@react-spectrum/s2/src/Toast.tsx +++ b/packages/@react-spectrum/s2/src/Toast.tsx @@ -579,7 +579,8 @@ export function SpectrumToast(props: SpectrumToastProps): ReactNode { index, isExpanded }) - }> + } + {...filterDOMProps(toast.content)}>
diff --git a/packages/@react-spectrum/s2/test/Toast.test.tsx b/packages/@react-spectrum/s2/test/Toast.test.tsx new file mode 100644 index 00000000000..ddf9391015c --- /dev/null +++ b/packages/@react-spectrum/s2/test/Toast.test.tsx @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import {act, installPointerEvent, pointerMap, render} from '@react-spectrum/test-utils-internal'; +import {Button} from '../src/Button'; +import {ToastContainer, ToastOptions, ToastQueue} from '../src/Toast'; +import userEvent from '@testing-library/user-event'; + +function Example(options: ToastOptions = {}) { + return ( + <> + + + + ); +} + +describe('Toast', () => { + installPointerEvent(); + + let user; + beforeAll(() => { + user = userEvent.setup({delay: null, pointerMap}); + }); + + beforeEach(() => { + jest.useFakeTimers(); + }); + + afterEach(() => { + act(() => jest.runAllTimers()); + }); + + it('passes an id and data attribute through to the rendered toast', async () => { + let {getByRole, getByTestId} = render( + // @ts-ignore + + ); + + let button = getByRole('button'); + await user.click(button); + + let toast = getByRole('alertdialog'); + expect(toast).toBeVisible(); + expect(toast).toHaveAttribute('id', 'toast-1'); + expect(toast).toHaveAttribute('data-testid', 'toast-1'); + expect(getByTestId('toast-1')).toBe(toast); + }); +}); diff --git a/starters/docs/src/TokenField.tsx b/starters/docs/src/TokenField.tsx index ed6bbb90bcc..e390e6f1a06 100644 --- a/starters/docs/src/TokenField.tsx +++ b/starters/docs/src/TokenField.tsx @@ -3,10 +3,10 @@ import { TokenField as AriaTokenField, TokenInput as AriaTokenInput, Token as AriaToken, - TokenFieldProps as AriaTokenFieldProps, - TokenInputProps, - TokenProps, - TokenFieldValue + type TokenFieldProps as AriaTokenFieldProps, + type TokenInputProps, + type TokenProps, + type TokenFieldValue } from 'react-aria-components/TokenField'; import {Label, Description} from './Form'; import './TokenField.css';