Skip to content

Commit

Permalink
feat(combobox): add support for computeStyle prop for popover positio…
Browse files Browse the repository at this point in the history
…ning
  • Loading branch information
anuradha9712 committed Jun 13, 2024
1 parent 872648f commit 0471090
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 231 deletions.
15 changes: 14 additions & 1 deletion core/components/organisms/combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ export const Combobox = (props: ComboboxProps) => {

const inputTriggerRef = React.useRef<HTMLInputElement>();
const popoverId = `DesignSystem-Combobox--Popover-${uidGenerator()}`;
const defaultPopoverStyle = {
fn: (data: any) => {
return {
...data,
styles: {
...data.styles,
position: 'fixed',
},
};
},
};

const popoverComputeStyle = computeStyles ?? defaultPopoverStyle;

React.useEffect(() => {
const popperWidth = triggerRef.current?.clientWidth;
Expand Down Expand Up @@ -297,7 +310,7 @@ export const Combobox = (props: ComboboxProps) => {
customStyle={popoverStyle}
onToggle={onToggleHandler}
trigger={<ComboboxTrigger {...triggerProps} />}
computeStyles={computeStyles}
computeStyles={popoverComputeStyle}
>
<div style={wrapperStyle} ref={listRef} id={popoverId}>
{children && typeof children === 'function' ? children(contextProp) : children}
Expand Down
230 changes: 0 additions & 230 deletions core/components/organisms/combobox/__stories__/computeStyle.story.jsx

This file was deleted.

0 comments on commit 0471090

Please sign in to comment.