From b436c4a4da647727ec608cf4c542ea2ba965ba34 Mon Sep 17 00:00:00 2001 From: Xaviju Date: Tue, 8 Oct 2024 12:52:53 +0200 Subject: [PATCH] test: fix tests --- libs/plugins-runtime/src/lib/assets/resize.svg | 2 +- libs/plugins-runtime/src/lib/create-modal.spec.ts | 6 +----- libs/plugins-runtime/src/lib/create-modal.ts | 8 ++++++-- libs/plugins-runtime/src/lib/modal/plugin.modal.css | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/plugins-runtime/src/lib/assets/resize.svg b/libs/plugins-runtime/src/lib/assets/resize.svg index 956459c0..bfcebe5f 100644 --- a/libs/plugins-runtime/src/lib/assets/resize.svg +++ b/libs/plugins-runtime/src/lib/assets/resize.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/libs/plugins-runtime/src/lib/create-modal.spec.ts b/libs/plugins-runtime/src/lib/create-modal.spec.ts index 7cabbcec..6910dbb5 100644 --- a/libs/plugins-runtime/src/lib/create-modal.spec.ts +++ b/libs/plugins-runtime/src/lib/create-modal.spec.ts @@ -44,10 +44,6 @@ describe('createModal', () => { '--modal-block-start', '40px' ); - expect(modal.style.setProperty).toHaveBeenCalledWith( - '--modal-inline-end', - '320px' - ); expect(modal.setAttribute).toHaveBeenCalledWith('title', 'Test Modal'); expect(modal.setAttribute).toHaveBeenCalledWith( @@ -83,7 +79,7 @@ describe('createModal', () => { options ); - const expectedWidth = 680; // 1000 - 320 (initialPosition.inlineEnd) + const expectedWidth = 730; // 1000 - 270 (initialPosition.inlineEnd) const expectedHeight = 760; // 800 - 40 (initialPosition.blockStart) expect(modal.setAttribute).toHaveBeenCalledWith( diff --git a/libs/plugins-runtime/src/lib/create-modal.ts b/libs/plugins-runtime/src/lib/create-modal.ts index 814c216a..f80da945 100644 --- a/libs/plugins-runtime/src/lib/create-modal.ts +++ b/libs/plugins-runtime/src/lib/create-modal.ts @@ -18,11 +18,16 @@ export function createModal( const defaultWidth = 335; const defaultHeight = 590; + const maxWidth = + (options?.width ?? defaultWidth) > window.innerWidth + ? window.innerWidth - 270 + : options?.width ?? defaultWidth; + const initialPosition = { blockStart: 40, // To be able to resize the element as expected the position must be absolute from the right. // This value is the length of the window minus the width of the element plus the width of the design tab. - inlineStart: window.innerWidth - defaultWidth - 270, + inlineStart: window.innerWidth - maxWidth - 270, }; modal.style.setProperty( @@ -34,7 +39,6 @@ export function createModal( `${initialPosition.inlineStart}px` ); - const maxWidth = window.innerWidth - initialPosition.inlineStart; const maxHeight = window.innerHeight - initialPosition.blockStart; let width = Math.min(options?.width || defaultWidth, maxWidth); let height = Math.min(options?.height || defaultHeight, maxHeight); diff --git a/libs/plugins-runtime/src/lib/modal/plugin.modal.css b/libs/plugins-runtime/src/lib/modal/plugin.modal.css index 61e243cd..5e050b45 100644 --- a/libs/plugins-runtime/src/lib/modal/plugin.modal.css +++ b/libs/plugins-runtime/src/lib/modal/plugin.modal.css @@ -26,7 +26,7 @@ } ::-webkit-resizer { - display: none;/ + display: none; } .wrapper {