UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

17 lines (15 loc) 578 B
import React from 'react'; import {createElemPropsHook} from '@workday/canvas-kit-react/common'; import {useComboboxModel} from './useComboboxModel'; /** * Sets the width of the Menu to the target element when the menu is visible */ export const useSetPopupWidth = createElemPropsHook(useComboboxModel)(model => { const visible = model.state.visibility !== 'hidden'; React.useLayoutEffect(() => { if (visible) { model.events.setWidth(model.state.targetRef.current?.clientWidth || 0); } }, [visible, model.events, model.state.targetRef]); return {}; });