Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaviju committed Oct 8, 2024
1 parent 7de4379 commit b436c4a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libs/plugins-runtime/src/lib/assets/resize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions libs/plugins-runtime/src/lib/create-modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 6 additions & 2 deletions libs/plugins-runtime/src/lib/create-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libs/plugins-runtime/src/lib/modal/plugin.modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}

::-webkit-resizer {
display: none;/
display: none;
}

.wrapper {
Expand Down

0 comments on commit b436c4a

Please sign in to comment.