Skip to content

Commit a5de60f

Browse files
authored
fix: Use correct box model when observing for changes (#164)
1 parent e30bc99 commit a5de60f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/container-queries/__tests__/use-container-query.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function TestComponent({ mapFn = () => '' }: { mapFn?: (entry: ContainerQueryEnt
1414

1515
test('should create a resize observer and observe the attached element', () => {
1616
const component = render(<TestComponent />);
17-
expect(ResizeObserver.prototype.observe).toHaveBeenCalledWith(component.getByTestId('test'));
17+
expect(ResizeObserver.prototype.observe).toHaveBeenCalledWith(component.getByTestId('test'), { box: 'border-box' });
1818
});
1919

2020
test('should call the map function with the content box when the resize observer is triggered', () => {

src/internal/container-queries/__tests__/use-resize-observer.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function TestComponent({ mapFn = () => '' }: { mapFn?: (entry: ContainerQueryEnt
2626

2727
test('should create a resize observer and observe the attached element', () => {
2828
const component = render(<TestComponent />);
29-
expect(ResizeObserver.prototype.observe).toHaveBeenCalledWith(component.getByTestId('test'));
29+
expect(ResizeObserver.prototype.observe).toHaveBeenCalledWith(component.getByTestId('test'), { box: 'border-box' });
3030
});
3131

3232
test('should call the map function with the content box when the resize observer is triggered', () => {

src/internal/container-queries/use-resize-observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function useResizeObserver(elementRef: ElementReference, onObserve: (entr
6262
});
6363
}
6464
});
65-
observer.observe(element);
65+
observer.observe(element, { box: 'border-box' });
6666
return () => {
6767
connected = false;
6868
observer.disconnect();

0 commit comments

Comments
 (0)