Skip to content

Commit a55baba

Browse files
committed
Fix x position logic in SelectContainer
1 parent 58317d1 commit a55baba

File tree

1 file changed

+2
-3
lines changed
  • packages/components/src/components/Select

1 file changed

+2
-3
lines changed

packages/components/src/components/Select/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ export function SelectContainer({
228228
// 요소가 움직일 때마다(스크롤, 리사이즈 등) 위치를 갱신하도록 이벤트를 등록합니다.
229229
const updatePosition = () => {
230230
const {
231-
width,
232231
height,
233232
x: comboboxX,
234233
y: comboboxY,
@@ -241,15 +240,15 @@ export function SelectContainer({
241240
document.documentElement.scrollHeight
242241

243242
const isOverflowRight =
244-
el.offsetWidth + left + window.scrollX + width + x >
243+
el.offsetWidth + left + window.scrollX + x >
245244
document.documentElement.scrollWidth
246245

247246
if (isOverflowBottom)
248247
el.style.bottom = `${window.innerHeight - comboboxY + 10}px`
249248
else el.style.top = `${comboboxY + height + 10 + y}px`
250249

251250
if (isOverflowRight)
252-
el.style.left = `${comboboxX - el.offsetWidth + combobox.offsetWidth + x}px`
251+
el.style.left = `${Math.max(comboboxX - el.offsetWidth + combobox.offsetWidth + x, 0)}px`
253252
else el.style.left = `${comboboxX + x}px`
254253
}
255254

0 commit comments

Comments
 (0)