diff --git a/.yarn/versions/261663d9.yml b/.yarn/versions/261663d9.yml
new file mode 100644
index 0000000000..bf4803d129
--- /dev/null
+++ b/.yarn/versions/261663d9.yml
@@ -0,0 +1,6 @@
+releases:
+ "@radix-ui/react-alert-dialog": patch
+ "@radix-ui/react-dialog": patch
+
+declined:
+ - primitives
diff --git a/packages/react/dialog/src/Dialog.test.tsx b/packages/react/dialog/src/Dialog.test.tsx
index fd62e6732e..1b37dab287 100644
--- a/packages/react/dialog/src/Dialog.test.tsx
+++ b/packages/react/dialog/src/Dialog.test.tsx
@@ -49,6 +49,8 @@ describe('given a default Dialog', () => {
let closeButton: HTMLElement;
let consoleWarnMock: jest.SpyInstance;
let consoleWarnMockFunction: jest.Mock;
+ let consoleErrorMock: jest.SpyInstance;
+ let consoleErrorMockFunction: jest.Mock;
beforeEach(() => {
// This surpresses React error boundary logs for testing intentionally
@@ -56,6 +58,8 @@ describe('given a default Dialog', () => {
// this here: https://github.com/facebook/react/issues/11098
consoleWarnMockFunction = jest.fn();
consoleWarnMock = jest.spyOn(console, 'warn').mockImplementation(consoleWarnMockFunction);
+ consoleErrorMockFunction = jest.fn();
+ consoleErrorMock = jest.spyOn(console, 'error').mockImplementation(consoleErrorMockFunction);
rendered = render();
trigger = rendered.getByText(OPEN_TEXT);
@@ -64,6 +68,8 @@ describe('given a default Dialog', () => {
afterEach(() => {
consoleWarnMock.mockRestore();
consoleWarnMockFunction.mockClear();
+ consoleErrorMock.mockRestore();
+ consoleErrorMockFunction.mockClear();
});
it('should have no accessibility violations in default state', async () => {
@@ -83,10 +89,15 @@ describe('given a default Dialog', () => {
});
describe('when no title has been provided', () => {
- it('should throw an error', () =>
- expect(() => {
- renderAndClickDialogTrigger();
- }).toThrowError());
+ beforeEach(() => {
+ cleanup();
+ });
+ it('should display an error in the console', () => {
+ consoleErrorMockFunction.mockClear();
+
+ renderAndClickDialogTrigger();
+ expect(consoleErrorMockFunction).toHaveBeenCalled();
+ });
});
describe('when aria-describedby is set to undefined', () => {
diff --git a/packages/react/dialog/src/Dialog.tsx b/packages/react/dialog/src/Dialog.tsx
index 940cc2e014..ab6de9a5e3 100644
--- a/packages/react/dialog/src/Dialog.tsx
+++ b/packages/react/dialog/src/Dialog.tsx
@@ -514,7 +514,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
React.useEffect(() => {
if (titleId) {
const hasTitle = document.getElementById(titleId);
- if (!hasTitle) throw new Error(MESSAGE);
+ if (!hasTitle) console.error(MESSAGE);
}
}, [MESSAGE, titleId]);