Skip to content
Open
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
7 changes: 7 additions & 0 deletions .changeset/sharp-steaks-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@ultraviolet/ui": patch
---

`SelectInput`:
- click outside should work in every context
- fix placeholder alignment when small
23 changes: 23 additions & 0 deletions packages/ui/src/components/SelectInput/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,29 @@ export const Dropdown = ({
)
const modalContext = useContext(ModalContext)

const handleClickOutside = useCallback(
(event: MouseEvent) => {
if (
event.target instanceof Node &&
ref.current &&
!ref.current.contains(event.target) &&
refSelect.current &&
!refSelect.current.contains(event.target)
) {
setIsDropdownVisible(false)
}
},
[setIsDropdownVisible, refSelect],
)

useEffect(() => {
document.addEventListener('mouseup', handleClickOutside)

return () => {
document.removeEventListener('mouseup', handleClickOutside)
}
}, [handleClickOutside])

Comment on lines +642 to +664
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already handled into the popup component it makes a duplicate. Maybe the issue is related to popup?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lisalupi WDYT about that ? I agree with matthprost It should already be handled by the Popup component 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will go back to this pr once I am done with vanilla extract ^^

useEffect(() => {
if (refSelect.current && isDropdownVisible) {
const position =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ type DisplayValuesProps = {
refPlusTag: RefObject<HTMLDivElement | null>
displayShadowCopy?: boolean
}

const DisplayValues = ({
refTag,
nonOverflowedValues,
Expand Down
Loading