We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The issue occurs when a Select item has more content than the screen viewport width.
When the content of an item in a select, it goes out of the screen:
The Select should be in left: 0 position and not get out of the screen.
left: 0
https://codesandbox.io/p/sandbox/peaceful-moore-57lrc4
(I'm not quite sure about the rtl solution)
rtl
diff --git c/packages/react/select/src/Select.tsx w/packages/react/select/src/Select.tsx index 11d0ba5b..a04f5fe2 100644 --- c/packages/react/select/src/Select.tsx +++ w/packages/react/select/src/Select.tsx @@ -802,17 +802,25 @@ const SelectItemAlignedPosition = React.forwardRef< const valueNodeRect = context.valueNode.getBoundingClientRect(); const itemTextRect = selectedItemText.getBoundingClientRect(); + console.log('selectedItemText', selectedItemText); + if (context.dir !== 'rtl') { const itemTextOffset = itemTextRect.left - contentRect.left; const left = valueNodeRect.left - itemTextOffset; const leftDelta = triggerRect.left - left; const minContentWidth = triggerRect.width + leftDelta; const contentWidth = Math.max(minContentWidth, contentRect.width); - const rightEdge = window.innerWidth - CONTENT_MARGIN; - const clampedLeft = clamp(left, [CONTENT_MARGIN, rightEdge - contentWidth]); - contentWrapper.style.minWidth = minContentWidth + 'px'; - contentWrapper.style.left = clampedLeft + 'px'; + if (contentWidth >= window.innerWidth) { + contentWrapper.style.left = CONTENT_MARGIN + 'px'; + contentWrapper.style.maxWidth = window.innerWidth - CONTENT_MARGIN * 2 + 'px'; + } else { + const rightEdge = + contentWidth <= window.innerWidth ? window.innerWidth - CONTENT_MARGIN : contentWidth; + const clampedLeft = clamp(left, [CONTENT_MARGIN, rightEdge - contentWidth]); + contentWrapper.style.left = clampedLeft + 'px'; + contentWrapper.style.minWidth = minContentWidth + 'px'; + } } else { const itemTextOffset = contentRect.right - itemTextRect.right; const right = window.innerWidth - valueNodeRect.right - itemTextOffset; @@ -822,8 +830,13 @@ const SelectItemAlignedPosition = React.forwardRef< const leftEdge = window.innerWidth - CONTENT_MARGIN; const clampedRight = clamp(right, [CONTENT_MARGIN, leftEdge - contentWidth]); - contentWrapper.style.minWidth = minContentWidth + 'px'; - contentWrapper.style.right = clampedRight + 'px'; + if (contentWidth >= window.innerWidth) { + contentWrapper.style.right = window.innerWidth - CONTENT_MARGIN + 'px'; + contentWrapper.style.maxWidth = window.innerWidth - CONTENT_MARGIN * 2 + 'px'; + } else { + contentWrapper.style.minWidth = minContentWidth + 'px'; + contentWrapper.style.right = clampedRight + 'px'; + } } // -----------------------------------------------------------------------------------------
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Bug report
The issue occurs when a Select item has more content than the screen viewport width.
Current Behavior
When the content of an item in a select, it goes out of the screen:
Expected behavior
The Select should be in
left: 0
position and not get out of the screen.Reproducible example
https://codesandbox.io/p/sandbox/peaceful-moore-57lrc4
Suggested solution
(I'm not quite sure about the
rtl
solution)Your environment
The text was updated successfully, but these errors were encountered: