Skip to content

useComboBox and --trigger-width #5656

Answered by reidbarber
luansantosti asked this question in Q&A
Discussion options

You must be logged in to vote

There isn't one included, but you could include the same feature in your component:

// Make menu width match input + button
let [menuWidth, setMenuWidth] = useState<string | null>(null);
let onResize = useCallback(() => {
if (inputRef.current) {
let buttonRect = buttonRef.current?.getBoundingClientRect();
let inputRect = inputRef.current.getBoundingClientRect();
let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;
let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;
setMenuWidth((m…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@luansantosti
Comment options

Answer selected by luansantosti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants