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
4 changes: 2 additions & 2 deletions packages/mask-markup/src/components/__tests__/blank.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ describe('Blank', () => {
const chip = wrapper && wrapper.firstChild; // StyledChip (rootRef)

// Width and height should include padding (24px) around measured content
expect(chip.style.width).toBe('124px');
expect(chip.style.height).toBe('44px');
expect(chip.style.width).toBe('129px');
expect(chip.style.height).toBe('49px');

rectSpy.mockRestore();
jest.useRealTimers();
Expand Down
14 changes: 10 additions & 4 deletions packages/mask-markup/src/components/blank.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,29 @@ function BlankContent({
const measureNode = getMeasureNode();
const node = measureNode || spanRef.current;
const rect = node.getBoundingClientRect();
const width = rect.width || node.offsetWidth || 0;
const width = node.offsetWidth || rect.width || 0;
const height = Math.max(
rect.height || 0,
node.offsetHeight || 0,
rect.height || 0,
node.scrollHeight || 0,
spanRef.current.scrollHeight || 0,
);

const widthWithPadding = width + 24; // 12px padding on each side
const heightWithPadding = height + 24; // 12px padding on top and bottom
const PADDING = 12;
const BORDER_WIDTH = 2;
const ADDITIONAL_SPACE = 1;
// padding and border on each side
const widthWithPadding = width + 2 * PADDING + 2 * BORDER_WIDTH + ADDITIONAL_SPACE;
// padding and border on top and bottom
const heightWithPadding = height + 2 * PADDING + 2 * BORDER_WIDTH + ADDITIONAL_SPACE;

const responseAreaWidth = parseFloat(emptyResponseAreaWidth) || 0;
const responseAreaHeight = parseFloat(emptyResponseAreaHeight) || 0;

const adjustedWidth = widthWithPadding <= responseAreaWidth ? responseAreaWidth : widthWithPadding;
const adjustedHeight = heightWithPadding <= responseAreaHeight ? responseAreaHeight : heightWithPadding;


setDimensions((prevState) => ({
width: adjustedWidth > responseAreaWidth ? adjustedWidth : prevState.width,
height: adjustedHeight > responseAreaHeight ? adjustedHeight : prevState.height,
Expand Down
Loading