Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 1b5ad3e

Browse files
authored
fix: arrow not positioned properly at initialisation #393 (#394)
1 parent 68a992c commit 1b5ad3e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/usePopper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const usePopper = (
4545
left: '0',
4646
top: '0',
4747
},
48+
arrow: {
49+
position: 'absolute',
50+
},
4851
},
4952
attributes: {},
5053
});

src/usePopper.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,24 @@ describe('userPopper', () => {
9090

9191
expect(destroy).toHaveBeenCalled();
9292
});
93+
94+
it('Initializes the arrow positioning', async () => {
95+
const arrowElement = document.createElement('div');
96+
const popperElementWithArrow = document.createElement('div');
97+
popperElementWithArrow.appendChild(arrowElement);
98+
99+
const { result, waitForNextUpdate } = renderHook(() =>
100+
usePopper(referenceElement, popperElementWithArrow, {
101+
placement: "bottom",
102+
modifiers: [{ name: "arrow", options: { element: arrowElement } }]
103+
})
104+
);
105+
106+
expect(result.current.styles.arrow.position).toBe('absolute');
107+
expect(result.current.styles.arrow.transform).toBeUndefined();
108+
109+
await waitForNextUpdate();
110+
111+
expect(result.current.styles.arrow.transform).toBeDefined();
112+
});
93113
});

0 commit comments

Comments
 (0)