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

🎨 Popover legger seg nå ikke over Input i Datepicker #2349

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/eighty-pants-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---

Datepicker: Popover legger seg nå ikke over input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"over" kan misforstås som "oppå". Hva med "ovenfor"?

KenAJoh marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions @navikt/core/react/src/date/datepicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
strategy={strategy}
className="navds-date__popover"
bubbleEscape={bubbleEscape}
flip={false}
>
<DayPicker
locale={getLocaleFromString(locale)}
Expand Down
1 change: 1 addition & 0 deletions @navikt/core/react/src/date/monthpicker/MonthPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
className="navds-date navds-date__popover"
strategy={strategy}
bubbleEscape={bubbleEscape}
flip={false}
>
<RootProvider
locale={getLocaleFromString(locale)}
Expand Down
8 changes: 7 additions & 1 deletion @navikt/core/react/src/popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
* @default false
*/
bubbleEscape?: boolean;
/**
* Changes placement of the floating element in order to keep it in view.
* @default true
*/
flip?: boolean;
}

interface PopoverComponent
Expand Down Expand Up @@ -121,6 +126,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
offset,
strategy: userStrategy,
bubbleEscape = false,
flip: _flip = true,
...rest
},
ref
Expand All @@ -145,7 +151,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
onOpenChange: () => onClose(),
middleware: [
flOffset(offset ?? (arrow ? 16 : 4)),
flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
_flip && flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
shift({ padding: 12 }),
flArrow({ element: arrowRef, padding: 8 }),
],
Expand Down
38 changes: 19 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4242,7 +4242,7 @@ __metadata:
languageName: node
linkType: hard

"@navikt/aksel-icons@^5.6.1, @navikt/aksel-icons@workspace:@navikt/aksel-icons":
"@navikt/aksel-icons@^5.6.3, @navikt/aksel-icons@workspace:@navikt/aksel-icons":
version: 0.0.0-use.local
resolution: "@navikt/aksel-icons@workspace:@navikt/aksel-icons"
dependencies:
Expand All @@ -4269,8 +4269,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@navikt/aksel-stylelint@workspace:@navikt/aksel-stylelint"
dependencies:
"@navikt/ds-css": ^5.6.1
"@navikt/ds-tokens": ^5.6.1
"@navikt/ds-css": ^5.6.3
"@navikt/ds-tokens": ^5.6.3
"@types/jest": ^29.0.0
concurrently: 7.2.1
copyfiles: 2.4.1
Expand All @@ -4288,7 +4288,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@navikt/aksel@workspace:@navikt/aksel"
dependencies:
"@navikt/ds-css": 5.6.1
"@navikt/ds-css": 5.6.3
"@types/inquirer": ^9.0.3
"@types/jest": ^29.0.0
axios: 1.3.6
Expand All @@ -4312,11 +4312,11 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-css@*, @navikt/ds-css@5.6.1, @navikt/ds-css@^5.6.1, @navikt/ds-css@workspace:@navikt/core/css":
"@navikt/ds-css@*, @navikt/ds-css@5.6.3, @navikt/ds-css@^5.6.3, @navikt/ds-css@workspace:@navikt/core/css":
version: 0.0.0-use.local
resolution: "@navikt/ds-css@workspace:@navikt/core/css"
dependencies:
"@navikt/ds-tokens": ^5.6.1
"@navikt/ds-tokens": ^5.6.3
cssnano: 6.0.0
fast-glob: 3.2.11
lodash: 4.17.21
Expand All @@ -4329,13 +4329,13 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-react@*, @navikt/ds-react@5.6.1, @navikt/ds-react@^5.6.1, @navikt/ds-react@workspace:@navikt/core/react":
"@navikt/ds-react@*, @navikt/ds-react@5.6.3, @navikt/ds-react@^5.6.3, @navikt/ds-react@workspace:@navikt/core/react":
version: 0.0.0-use.local
resolution: "@navikt/ds-react@workspace:@navikt/core/react"
dependencies:
"@floating-ui/react": 0.25.4
"@navikt/aksel-icons": ^5.6.1
"@navikt/ds-tokens": ^5.6.1
"@navikt/aksel-icons": ^5.6.3
"@navikt/ds-tokens": ^5.6.3
"@radix-ui/react-tabs": 1.0.0
"@radix-ui/react-toggle-group": 1.0.0
"@testing-library/dom": 8.13.0
Expand Down Expand Up @@ -4369,11 +4369,11 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-tailwind@^5.6.1, @navikt/ds-tailwind@workspace:@navikt/core/tailwind":
"@navikt/ds-tailwind@^5.6.3, @navikt/ds-tailwind@workspace:@navikt/core/tailwind":
version: 0.0.0-use.local
resolution: "@navikt/ds-tailwind@workspace:@navikt/core/tailwind"
dependencies:
"@navikt/ds-tokens": ^5.6.1
"@navikt/ds-tokens": ^5.6.3
"@types/jest": ^29.0.0
color: 4.2.3
jest: ^29.0.0
Expand All @@ -4384,7 +4384,7 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-tokens@^5.6.1, @navikt/ds-tokens@workspace:@navikt/core/tokens":
"@navikt/ds-tokens@^5.6.3, @navikt/ds-tokens@workspace:@navikt/core/tokens":
version: 0.0.0-use.local
resolution: "@navikt/ds-tokens@workspace:@navikt/core/tokens"
dependencies:
Expand Down Expand Up @@ -9214,11 +9214,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "aksel.nav.no@workspace:aksel.nav.no"
dependencies:
"@navikt/aksel-icons": ^5.6.1
"@navikt/ds-css": ^5.6.1
"@navikt/ds-react": ^5.6.1
"@navikt/ds-tailwind": ^5.6.1
"@navikt/ds-tokens": ^5.6.1
"@navikt/aksel-icons": ^5.6.3
"@navikt/ds-css": ^5.6.3
"@navikt/ds-react": ^5.6.3
"@navikt/ds-tailwind": ^5.6.3
"@navikt/ds-tokens": ^5.6.3
prettier-plugin-tailwindcss: ^0.2.3
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -24181,8 +24181,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "shadow-dom@workspace:examples/shadow-dom"
dependencies:
"@navikt/ds-css": 5.6.1
"@navikt/ds-react": 5.6.1
"@navikt/ds-css": 5.6.3
"@navikt/ds-react": 5.6.3
"@types/react": ^18.0.0
"@types/react-dom": ^18.0.0
"@vitejs/plugin-react": ^3.1.0
Expand Down