Skip to content
New issue

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

Fix select menu position issue 67 #203

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-select-menu-bottom-placment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudoperators/juno-ui-components": patch
---

Fix select menu position issue 67 by switching from `flip()` to `autoPlacment()` placement strategy in headless ui middleware.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { Spinner } from "../Spinner/Spinner.component"
import { FormHint } from "../FormHint/FormHint.component"
import { Float } from "@headlessui-float/react"
import { flip, offset, shift, size } from "@floating-ui/react-dom"
import { autoPlacement, flip, offset, shift, size } from "@floating-ui/react-dom"

Check failure on line 14 in packages/ui-components/src/components/Select/Select.component.js

View workflow job for this annotation

GitHub Actions / lint

'flip' is defined but never used. Allowed unused vars must match /^_/u
import { usePortalRef } from "../PortalProvider/index"
import { createPortal } from "react-dom"
import "./select.scss"
Expand Down Expand Up @@ -169,8 +169,14 @@
// Headless-UI-Float Middleware
const middleware = [
offset(4),
shift(),
flip(),
autoPlacement((state) =>
// Uncomment to examine Headless-UI-Floating middleware:

Check failure on line 173 in packages/ui-components/src/components/Select/Select.component.js

View workflow job for this annotation

GitHub Actions / lint

'state' is defined but never used. Allowed unused args must match /^_/u
// console.log(state),
({
crossAxis: true,
allowedPlacements: ["bottom", "top"],
})
),
size({
boundary: "viewport",
apply({ availableWidth, availableHeight, elements }) {
Expand All @@ -181,6 +187,7 @@
})
},
}),
shift(),
]

// This function is used to determine what to render for the selected options in the Select Toggle in multi-select case.
Expand Down
23 changes: 23 additions & 0 deletions packages/ui-components/src/components/Select/Select.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@
children: PropTypes.node,
}

const BottomPositionTemplate = ({ parentStyles, children, ...args }) => (

Check failure on line 87 in packages/ui-components/src/components/Select/Select.stories.js

View workflow job for this annotation

GitHub Actions / lint

'parentStyles' is missing in props validation

Check failure on line 87 in packages/ui-components/src/components/Select/Select.stories.js

View workflow job for this annotation

GitHub Actions / lint

'children' is missing in props validation
<div style={parentStyles}>
Bottom Positioned Select
<Select {...args}>{children}</Select>
</div>
)

export const Default = {
render: Template,
args: {
Expand Down Expand Up @@ -535,3 +542,19 @@
],
},
}

export const BottomPositionedSelect = {
render: BottomPositionTemplate,
args: {
parentStyles: {
position: "absolute",
bottom: "0",
},
children: [
<SelectOption key="1" value="Option 1" />,
<SelectOption key="2" value="Option 2" />,
<SelectOption key="3" value="Option 3" />,
<SelectOption key="4" value="Option 4" />,
],
},
}
Loading