Skip to content

Commit

Permalink
feat: prioritizePosition props for popper
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Jan 31, 2024
1 parent 60b6f39 commit dc4e3e7
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/content/meta/ComboboxContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
'type': '\'inline\' | \'popper\'',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'side',
'description': '<p>The preferred side of the trigger to render against when open.\nWill be reversed when collisions occur and avoidCollisions\nis enabled.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/ContextMenuContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
'type': 'boolean',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'sticky',
'description': '<p>The sticky behavior on the align axis. <code>partial</code> will keep the\ncontent in the boundary as long as the trigger is at least partially\nin the boundary whilst &quot;always&quot; will keep the content in the boundary\nregardless.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/ContextMenuSubContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
'type': 'boolean',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'sideOffset',
'description': '<p>The distance in pixels from the trigger.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/DropdownMenuContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
'type': 'boolean',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'side',
'description': '<p>The preferred side of the trigger to render against when open.\nWill be reversed when collisions occur and avoidCollisions\nis enabled.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/DropdownMenuSubContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
'type': 'boolean',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'sideOffset',
'description': '<p>The distance in pixels from the trigger.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/HoverCardContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
'type': 'boolean',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'side',
'description': '<p>The preferred side of the trigger to render against when open.\nWill be reversed when collisions occur and avoidCollisions\nis enabled.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/MenubarContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
'type': 'boolean',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'side',
'description': '<p>The preferred side of the trigger to render against when open.\nWill be reversed when collisions occur and avoidCollisions\nis enabled.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/MenubarSubContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
'type': 'boolean',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'sideOffset',
'description': '<p>The distance in pixels from the trigger.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/PopoverContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
'type': 'boolean',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'side',
'description': '<p>The preferred side of the trigger to render against when open.\nWill be reversed when collisions occur and avoidCollisions\nis enabled.</p>\n',
Expand Down
6 changes: 6 additions & 0 deletions docs/content/meta/SelectContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
'type': '\'popper\' | \'item-aligned\'',
'required': false
},
{
'name': 'prioritizePosition',
'description': '<p>Force content to be position within the viewport.</p>\n<p>Might overlap the reference element, which may not be desired.</p>\n',
'type': 'boolean',
'required': false
},
{
'name': 'side',
'description': '<p>The preferred side of the trigger to render against when open.\nWill be reversed when collisions occur and avoidCollisions\nis enabled.</p>\n',
Expand Down
1 change: 1 addition & 0 deletions packages/radix-vue/src/Menu/MenuContentImpl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ provideMenuContentContext({
:collision-boundary="collisionBoundary"
:collision-padding="collisionPadding"
:arrow-padding="arrowPadding"
:prioritize-position="prioritizePosition"
:sticky="sticky"
:hide-when-detached="hideWhenDetached"
@keydown="handleKeyDown"
Expand Down
15 changes: 13 additions & 2 deletions packages/radix-vue/src/Popper/PopperContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const PopperContentPropsDefaultValue = {
sticky: 'partial' as 'partial' | 'always',
hideWhenDetached: false,
updatePositionStrategy: 'optimized' as 'optimized' | 'always',
prioritizePosition: false,
}
export interface PopperContentProps extends PrimitiveProps {
Expand Down Expand Up @@ -115,6 +116,15 @@ export interface PopperContentProps extends PrimitiveProps {
* @defaultValue 'optimized'
*/
updatePositionStrategy?: 'optimized' | 'always'
/**
* Force content to be position within the viewport.
*
* Might overlap the reference element, which may not be desired.
*
* @defaultValue false
*/
prioritizePosition?: boolean
}
export interface PopperContentContext {
Expand Down Expand Up @@ -205,11 +215,12 @@ const computedMiddleware = computedEager(() => {
props.avoidCollisions
&& shift({
mainAxis: true,
crossAxis: true,
crossAxis: !!props.prioritizePosition,
limiter: props.sticky === 'partial' ? limitShift() : undefined,
...detectOverflowOptions.value,
}),
props.avoidCollisions
!props.prioritizePosition
&& props.avoidCollisions
&& flip({
...detectOverflowOptions.value,
}),
Expand Down

0 comments on commit dc4e3e7

Please sign in to comment.