Skip to content

Commit 5872b50

Browse files
authored
Merge pull request #315 from belltalion/fix-select
Fix select componenet
2 parents f00a0c8 + 1f836c5 commit 5872b50

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.changeset/tired-mugs-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/components": patch
3+
---
4+
5+
Fix select

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,27 @@ export function SelectContainer({
228228
// 요소가 움직일 때마다(스크롤, 리사이즈 등) 위치를 갱신하도록 이벤트를 등록합니다.
229229
const updatePosition = () => {
230230
const {
231+
width,
231232
height,
232233
x: comboboxX,
233234
y: comboboxY,
235+
top,
236+
left,
234237
} = combobox.getBoundingClientRect()
235238

236-
if (el.offsetHeight + comboboxY + y > window.innerHeight)
239+
const isOverflowBottom =
240+
el.offsetHeight + top + window.scrollY + height + y >
241+
document.documentElement.scrollHeight
242+
243+
const isOverflowRight =
244+
el.offsetWidth + left + window.scrollX + width + x >
245+
document.documentElement.scrollWidth
246+
247+
if (isOverflowBottom)
237248
el.style.bottom = `${window.innerHeight - comboboxY + 10}px`
238249
else el.style.top = `${comboboxY + height + 10 + y}px`
239250

240-
if (el.offsetWidth + comboboxX + x > window.innerWidth)
251+
if (isOverflowRight)
241252
el.style.left = `${comboboxX - el.offsetWidth + combobox.offsetWidth + x}px`
242253
else el.style.left = `${comboboxX + x}px`
243254
}

0 commit comments

Comments
 (0)