Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
added maxHeight prop to support scrollable popover for Select faux
Browse files Browse the repository at this point in the history
component
  • Loading branch information
sbatel committed Nov 13, 2023
1 parent cba7ed8 commit 91442c8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/components/inputs/Select/Select.props.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,36 @@ export function FauxExternalState({ args }) {
}
FauxExternalState.storyName = 'faux (external state)';

export function FauxMaxHeight({ args }) {
const [value, valueSet] = useState(null);

function onChange(event) {
valueSet(event.target.value);
console.log('Selected Option', event.target.value, event);
}

return (
<Layout.StoryVertical>
<Select
{...args}
label="Faux select with maximum height"
onChange={onChange}
placeholder="Please select an option."
value={value}
faux
maxHeight="300px"
>
{Array.from({ length: 20 }, (_, index) => (
<Select.Option key={index} value={index}>{`Option ${
index + 1
}`}</Select.Option>
))}
</Select>
</Layout.StoryVertical>
);
}
FauxMaxHeight.storyName = 'faux (maximum height)';

const UpgradeBadge = (
<Badge
// @ts-ignore
Expand Down
4 changes: 4 additions & 0 deletions src/components/inputs/Select/Select.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export type Props = IrisInputProps<
*/
size?: Sizes;
value?: string | string[];
/**
* [default = '100%']
*/
maxHeight?: string;
},
HTMLSelectElement
>;
Expand Down
8 changes: 7 additions & 1 deletion src/components/inputs/Select/SelectFaux.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function SelectFaux({
size = 'md',
status,
style,
maxHeight = '100%',
value,
...props
}: Props) {
Expand Down Expand Up @@ -113,7 +114,12 @@ export function SelectFaux({
>
<PopOver
attach="bottom"
style={{ width, maxWidth: '100%' }}
style={{
width,
maxWidth: '100%',
maxHeight,
overflowY: 'scroll',
}}
content={<div ref={popOverRef}>{content}</div>}
active={disabled ? false : active}
>
Expand Down

0 comments on commit 91442c8

Please sign in to comment.