Skip to content

Commit

Permalink
add padding to flip and shift middleware (#2189)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank99 authored Aug 8, 2024
1 parent 49679a8 commit e1045a8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-onions-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': patch
---

Floating elements will now have a few pixels of padding from the edge of the viewport.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions packages/itwinui-react/src/core/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,18 @@ export const usePopover = (options: PopoverOptions & PopoverInternalProps) => {
() =>
[
middleware.offset !== undefined && offset(middleware.offset),
middleware.flip && flip(),
middleware.shift && shift(),
middleware.flip && flip({ padding: 4 }),
middleware.shift && shift({ padding: 4 }),
matchWidth &&
size({
padding: 4,
apply: ({ rects }) => {
setReferenceWidth(rects.reference.width);
},
} as SizeOptions),
middleware.autoPlacement && autoPlacement(),
middleware.autoPlacement && autoPlacement({ padding: 4 }),
middleware.inline && inline(),
middleware.hide && hide(),
middleware.hide && hide({ padding: 4 }),
].filter(Boolean),
[matchWidth, middleware],
),
Expand Down
10 changes: 5 additions & 5 deletions packages/itwinui-react/src/core/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ const useTooltip = (options: TooltipOptions = {}) => {
middleware.offset !== undefined
? offset(middleware.offset)
: offset(4),
middleware.flip && flip(),
middleware.shift && shift(),
middleware.size && size(),
middleware.autoPlacement && autoPlacement(),
middleware.flip && flip({ padding: 4 }),
middleware.shift && shift({ padding: 4 }),
middleware.size && size({ padding: 4 }),
middleware.autoPlacement && autoPlacement({ padding: 4 }),
middleware.inline && inline(),
middleware.hide && hide(),
middleware.hide && hide({ padding: 4 }),
].filter(Boolean),
[middleware],
),
Expand Down

0 comments on commit e1045a8

Please sign in to comment.