Skip to content

Commit

Permalink
🎨 Popover legger seg nå ikke over Input i Datepicker (#2349)
Browse files Browse the repository at this point in the history
* 🎨 Popover legger seg nå ikke over Input i Datepicker

* Update .changeset/eighty-pants-switch.md

* 📝 Yarn sync

* 📝 Yarn sync
  • Loading branch information
KenAJoh authored Oct 10, 2023
1 parent fcbf6ea commit e77568f
Show file tree
Hide file tree
Showing 5 changed files with 3,222 additions and 2,400 deletions.
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 ovenfor input
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
Loading

0 comments on commit e77568f

Please sign in to comment.