Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/feedback/src/modal/components/Dialog.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const FORM = `
.form__error-container {
color: var(--error-color);
fill: var(--error-color);
overflow-wrap: break-word;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap fix ineffective in flex layout

Medium Severity

overflow-wrap: break-word on .form__error-container does not reduce min-content size, so nested flex items (.form__top, .form__label, and the fieldset.form__right column) keep min-width: auto and still expand past the 272px panel. Long tokens can keep overflowing—especially in Firefox, where this was reported—so the dialog overflow likely remains.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit abd0224. Configure here.

}

.form__label {
Expand Down
42 changes: 42 additions & 0 deletions packages/feedback/test/modal/components/Dialog.css.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @vitest-environment jsdom
*/
import { describe, expect, it } from 'vitest';
import { createDialogStyles } from '../../../src/modal/components/Dialog.css';

/**
* Returns the declarations inside the first rule block matching `selector`, so
* assertions target one rule rather than the whole stylesheet.
*/
function getRuleBlock(css: string, selector: string): string {
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const match = new RegExp(`^${escaped}\\s*\\{([^}]*)\\}`, 'm').exec(css);
return match ? match[1] : '';
}

describe('createDialogStyles', () => {
it('lets long error messages wrap instead of overflowing the dialog', () => {
const css = createDialogStyles().textContent ?? '';
const rule = getRuleBlock(css, '.form__error-container');

// Guard: if the selector is renamed, fail loudly rather than pass vacuously.
expect(rule).not.toBe('');
// `FeedbackErrorMessages` lets integrators supply arbitrary error copy, and
// the container is only 272px wide while the screenshot editor is open, so a
// single long token must be breakable.
expect(rule).toMatch(/overflow-wrap:\s*break-word/);
});

it('keeps the error colour tokens on the same rule', () => {
const css = createDialogStyles().textContent ?? '';
const rule = getRuleBlock(css, '.form__error-container');

expect(rule).toMatch(/color:\s*var\(--error-color\)/);
expect(rule).toMatch(/fill:\s*var\(--error-color\)/);
});

it('applies the nonce when one is supplied', () => {
expect(createDialogStyles('abc123').getAttribute('nonce')).toBe('abc123');
expect(createDialogStyles().hasAttribute('nonce')).toBe(false);
});
});