Skip to content
Merged
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
69 changes: 30 additions & 39 deletions src/web-ui/src/app/components/FeedbackDialog/FeedbackDialog.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
.bitfun-feedback__overlay {
padding: 48px 40px 32px;
}
--bitfun-feedback-modal-max-height: calc(100vh - 80px);

.bitfun-feedback__overlay .modal {
width: min(960px, calc(100vw - 80px));
max-width: min(960px, calc(100vw - 80px));
max-height: calc(100vh - 80px);
padding: 48px clamp(12px, 5.882vw, 40px) 32px;
}

.bitfun-feedback__modal-content {
Expand All @@ -15,9 +11,7 @@
}

.bitfun-feedback__root {
display: flex;
flex: 1;
flex-direction: column;
width: 100%;
min-width: 0;
min-height: 0;
}
Expand All @@ -29,7 +23,8 @@
width: 100%;
min-width: 0;
min-height: 0;
height: min(620px, calc(100vh - 114px));
height: calc(100vh - 114px);
max-height: 620px;
}

.bitfun-feedback__view-switch {
Expand Down Expand Up @@ -84,7 +79,7 @@
flex-direction: column;
gap: 18px;
min-height: 0;
padding: 22px 26px 24px;
padding: 22px clamp(18px, 3.824vw, 26px) 24px;
overflow-y: auto;
}

Expand Down Expand Up @@ -192,26 +187,31 @@
.bitfun-feedback__actions {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
width: 100%;
min-width: 0;
margin-top: auto;

.btn {
flex-shrink: 0;
min-width: 96px;
}
}

.bitfun-feedback__action-spacer {
flex: 1;
.bitfun-feedback__primary-actions {
display: flex;
flex-shrink: 0;
align-items: center;
gap: 10px;
margin-left: auto;
}

.bitfun-feedback__complete {
display: flex;
flex: 1;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
min-height: min(460px, 64vh);
padding: 32px;
color: var(--bf-appearance-token-color-text-secondary);
text-align: center;
Expand Down Expand Up @@ -626,36 +626,27 @@
}
}

@media (max-width: 680px), (max-height: 540px) {
@media (max-width: 680px) {
.bitfun-feedback__overlay {
padding: 44px 12px 12px;
padding-right: clamp(12px, 5.882vw, 40px);
padding-left: clamp(12px, 5.882vw, 40px);
}

.bitfun-feedback__overlay .modal {
width: calc(100vw - 24px);
max-width: calc(100vw - 24px);
max-height: calc(100vh - 56px);
}

.bitfun-feedback__center {
height: calc(100vh - 90px);
}

.bitfun-feedback__form {
padding: 18px;
}

.bitfun-feedback__privacy,
.bitfun-feedback__actions {
align-items: stretch;
.bitfun-feedback__privacy {
align-items: center;
flex-wrap: wrap;
}
}

.bitfun-feedback__privacy {
align-items: center;
@media (max-height: 540px) {
.bitfun-feedback__overlay {
--bitfun-feedback-modal-max-height: calc(100vh - 56px);

padding-top: 44px;
padding-bottom: 12px;
}

.bitfun-feedback__action-spacer {
display: none;
.bitfun-feedback__center {
height: calc(100vh - 90px);
}
}
46 changes: 26 additions & 20 deletions src/web-ui/src/app/components/FeedbackDialog/FeedbackDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ export const FeedbackDialog: React.FC<FeedbackDialogProps> = ({ isOpen, onClose
onClose={requestClose}
title={t('header.feedback')}
size="xlarge"
dimensions={{
width: '100%',
maxWidth: completed ? 560 : 960,
maxHeight: 'var(--bitfun-feedback-modal-max-height)',
}}
overlayClassName="bitfun-feedback__overlay"
contentClassName="bitfun-feedback__modal-content"
showCloseButton={!submitting && !replyState.sending}
Expand Down Expand Up @@ -430,26 +435,27 @@ export const FeedbackDialog: React.FC<FeedbackDialogProps> = ({ isOpen, onClose
<ExternalLink size={15} aria-hidden="true" />
{t('feedback.actions.gitcode')}
</Button>
<span className="bitfun-feedback__action-spacer" />
<Button
type="button"
variant="secondary"
disabled={submitting}
onClick={requestClose}
>
{t('feedback.actions.cancel')}
</Button>
<Button
type="submit"
disabled={!canSubmit}
isLoading={submitting}
data-testid="feedback-submit"
>
<Send size={15} aria-hidden="true" />
{submitError instanceof FeedbackApiError && submitError.retryable
? t('feedback.actions.retry')
: t('feedback.actions.submit')}
</Button>
<div className="bitfun-feedback__primary-actions">
<Button
type="button"
variant="secondary"
disabled={submitting}
onClick={requestClose}
>
{t('feedback.actions.cancel')}
</Button>
<Button
type="submit"
disabled={!canSubmit}
isLoading={submitting}
data-testid="feedback-submit"
>
<Send size={15} aria-hidden="true" />
{submitError instanceof FeedbackApiError && submitError.retryable
? t('feedback.actions.retry')
: t('feedback.actions.submit')}
</Button>
</div>
</div>
</form>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { compile } from 'sass';
import { describe, expect, it } from 'vitest';

const readSource = (relativePath: string): string =>
Expand Down Expand Up @@ -67,14 +68,22 @@ describe('OpenHarmony feedback submission contract', () => {

it('shows a single completion action after capability-backed success', () => {
const dialog = readSource('./FeedbackDialog.tsx');
const styles = readSource('./FeedbackDialog.scss');
const completeView = dialog.slice(
dialog.indexOf('className="bitfun-feedback__complete"'),
dialog.indexOf(') : (\n <div ref={containerRef}'),
);
const completeStyles = styles.slice(
styles.indexOf('.bitfun-feedback__complete {'),
styles.indexOf('.bitfun-feedback__inbox-layout {'),
);

expect(completeView).toContain("t('shared:statuses.done')");
expect(completeView).not.toContain('openGitCode');
expect(completeView).not.toContain('feedback-submit');
expect(dialog).toContain('maxWidth: completed ? 560 : 960');
expect(completeStyles).not.toContain('min-height:');
expect(completeStyles).not.toContain('flex: 1;');
});

it('does not present an invalid zero-second quota retry', () => {
Expand Down Expand Up @@ -102,13 +111,48 @@ describe('OpenHarmony feedback submission contract', () => {
});

it('keeps the dialog below the host window controls at every supported size', () => {
const stylesheetPath = fileURLToPath(new URL('./FeedbackDialog.scss', import.meta.url));
const dialog = readSource('./FeedbackDialog.tsx');
const styles = readSource('./FeedbackDialog.scss');
const builtStyles = compile(stylesheetPath).css;
const actionStyles = styles.slice(
styles.indexOf('.bitfun-feedback__actions {'),
styles.indexOf('.bitfun-feedback__complete {'),
);

expect(styles).toContain('padding: 48px 40px 32px;');
expect(styles).toContain('width: min(960px, calc(100vw - 80px));');
expect(styles).toContain('height: min(620px, calc(100vh - 114px));');
expect(styles).toContain('padding: 44px 12px 12px;');
expect(styles).toContain('max-height: calc(100vh - 56px);');
expect(styles).toContain('padding: 48px clamp(12px, 5.882vw, 40px) 32px;');
expect(styles).toContain('padding: 22px clamp(18px, 3.824vw, 26px) 24px;');
expect(dialog).toContain('dimensions={{');
expect(dialog).toContain("width: '100%'");
expect(dialog).toContain('maxWidth: completed ? 560 : 960');
expect(dialog).toContain("maxHeight: 'var(--bitfun-feedback-modal-max-height)'");
expect(styles).toContain('--bitfun-feedback-modal-max-height: calc(100vh - 80px);');
expect(styles).toContain('height: calc(100vh - 114px);');
expect(styles).toContain('max-height: 620px;');
expect(styles).toContain('.bitfun-feedback__root {\n width: 100%;');
expect(styles).not.toContain('.bitfun-feedback__overlay > .modal');
expect(styles).not.toContain('min(960px, calc(100vw - 80px))');
expect(styles).not.toContain('min(620px, calc(100vh - 114px))');
expect(builtStyles).toContain('padding: 48px clamp(12px, 5.882vw, 40px) 32px;');
expect(builtStyles).toContain('height: calc(100vh - 114px);');
expect(builtStyles).not.toContain('min(960px, 100vw - 80px)');
expect(builtStyles).not.toContain('min(620px, 100vh - 114px)');
expect(styles).toContain('@media (max-width: 680px) {');
expect(styles).toContain('@media (max-height: 540px) {');
expect(styles).toContain('--bitfun-feedback-modal-max-height: calc(100vh - 56px);');
expect(styles).toContain('padding-top: 44px;');
expect(styles).toContain('padding-bottom: 12px;');
expect(dialog).toContain('<div className="bitfun-feedback__primary-actions">');
expect(dialog).not.toContain('bitfun-feedback__action-spacer');
expect(actionStyles).toContain('display: flex;');
expect(actionStyles).toContain('flex-wrap: wrap;');
expect(actionStyles).toContain('width: 100%;');
expect(actionStyles).toContain('min-width: 0;');
expect(actionStyles).toContain('.bitfun-feedback__primary-actions {');
expect(actionStyles).toContain('flex-shrink: 0;');
expect(actionStyles).toContain('margin-left: auto;');
expect(actionStyles).not.toContain('grid-template-columns:');
expect(styles).not.toContain('@media (max-width: 460px)');
});

it('keeps Mock request logs limited to a fixed stage and request id', () => {
Expand Down
43 changes: 43 additions & 0 deletions src/web-ui/src/component-library/components/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ describe('Modal behavior', () => {

afterEach(() => {
act(() => root.unmount());
document.querySelectorAll('style[data-bf-appearance-runtime="test"]')
.forEach(style => style.remove());
document.documentElement.removeAttribute('data-bf-appearance');
document.documentElement.removeAttribute('data-bf-appearance-revision');
container.remove();
vi.useRealTimers();
vi.restoreAllMocks();
Expand Down Expand Up @@ -90,6 +94,45 @@ describe('Modal behavior', () => {
expect(document.body.querySelector('.modal--exiting')).toBeNull();
});

it('keeps instance dimensions above late Appearance size rules', () => {
act(() => {
root.render(
<Modal
isOpen
onClose={vi.fn()}
size="xlarge"
dimensions={{
width: '100%',
maxWidth: 960,
maxHeight: 'calc(100vh - 80px)',
}}
>
Content
</Modal>,
);
});

const runtimeStyle = document.createElement('style');
runtimeStyle.setAttribute('data-bf-appearance-runtime', 'test');
runtimeStyle.textContent = `
:root[data-bf-appearance="builtin"][data-bf-appearance-revision="7"]
[data-bf-component="modal"][data-bf-part="dialog"][data-bf-size="xlarge"] {
width: 100%;
max-width: 720px;
max-height: 100%;
}
`;
document.documentElement.setAttribute('data-bf-appearance', 'builtin');
document.documentElement.setAttribute('data-bf-appearance-revision', '7');
document.head.appendChild(runtimeStyle);

const dialog = document.body.querySelector<HTMLElement>('[role="dialog"]');
expect(dialog?.style.width).toBe('100%');
expect(dialog?.style.maxWidth).toBe('960px');
expect(dialog?.style.maxHeight).toBe('calc(100vh - 80px)');
expect(dialog ? getComputedStyle(dialog).maxWidth : null).toBe('960px');
});

it('closes only when the pointer press and release both occur on the overlay', () => {
const onClose = vi.fn();
act(() => {
Expand Down
Loading
Loading