Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
02b434b
chore: add test page
TeodorTaushanov Nov 5, 2025
ceab536
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 5, 2025
4f1068a
chore: improve test page
TeodorTaushanov Nov 6, 2025
5f08774
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 6, 2025
d5f7f45
chore: render the resize corner icon
TeodorTaushanov Nov 6, 2025
d33a75f
chore: add ResizeHandlePlacement
TeodorTaushanov Nov 7, 2025
438208b
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 7, 2025
1882499
chore: add some resizing structure
TeodorTaushanov Nov 7, 2025
ae3b66b
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 10, 2025
ef6b0cd
chore: calc resizeHandlePlacement
TeodorTaushanov Nov 10, 2025
a167b86
chore: improve calculations
TeodorTaushanov Nov 10, 2025
7f946d3
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 10, 2025
6398e8e
chore: handle min sizes
TeodorTaushanov Nov 11, 2025
666b5d1
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 11, 2025
1161353
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 12, 2025
bb5f509
fix: resize icon placing in rtl mode
TeodorTaushanov Nov 13, 2025
1a05a21
fix: resize positioning when centered
TeodorTaushanov Nov 14, 2025
98d4d7d
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 14, 2025
bf1d23d
fix: fix re-resizing
TeodorTaushanov Nov 14, 2025
48abe1b
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 17, 2025
090e002
fix: clicking outside the resize handle icon
TeodorTaushanov Nov 17, 2025
c27c937
fix: lint error
TeodorTaushanov Nov 17, 2025
99b6fe9
chore: rename props
TeodorTaushanov Nov 17, 2025
a49c512
chore: add tests
TeodorTaushanov Nov 18, 2025
605912f
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 18, 2025
41cf755
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 18, 2025
19a4c91
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 18, 2025
0d7339b
chore: fix tests
TeodorTaushanov Nov 18, 2025
ad0f12c
chore: improve tests
TeodorTaushanov Nov 19, 2025
f1942bd
chore: improve tests
TeodorTaushanov Nov 19, 2025
506eac9
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 19, 2025
27c237d
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 20, 2025
a3dbd62
chore: override styles like in the Dialog
TeodorTaushanov Nov 20, 2025
6d543d9
chore: add public sample
TeodorTaushanov Nov 20, 2025
5161217
chore: fix typo
TeodorTaushanov Nov 20, 2025
5bb57bf
chore: improve public sample
TeodorTaushanov Nov 20, 2025
a0f162f
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 24, 2025
81110fc
chore: address code comments
TeodorTaushanov Nov 25, 2025
d8cacf2
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 25, 2025
f4e2455
chore: lower the flickering during resize
TeodorTaushanov Nov 25, 2025
54f49f8
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 25, 2025
c620987
chore: fix resizeHandlePlacement in RTL
TeodorTaushanov Nov 25, 2025
40d6e6b
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Nov 26, 2025
d96c5be
chore: improve documentation
TeodorTaushanov Nov 26, 2025
dd87554
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Dec 3, 2025
14b8684
chore: move resize logic into separate PopoverResize class
TeodorTaushanov Dec 4, 2025
d7b55c0
Merge remote-tracking branch 'origin/main' into popover_resize
TeodorTaushanov Dec 4, 2025
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
979 changes: 979 additions & 0 deletions packages/main/cypress/specs/PopoverResize.cy.tsx

Large diffs are not rendered by default.

86 changes: 77 additions & 9 deletions packages/main/src/Popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import { isIOS } from "@ui5/webcomponents-base/dist/Device.js";
import { getClosedPopupParent } from "@ui5/webcomponents-base/dist/util/PopupUtils.js";
import { isClickInRect, getClosedPopupParent } from "@ui5/webcomponents-base/dist/util/PopupUtils.js";
import clamp from "@ui5/webcomponents-base/dist/util/clamp.js";
import DOMReferenceConverter from "@ui5/webcomponents-base/dist/converters/DOMReference.js";
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
Expand All @@ -13,6 +13,7 @@ import PopoverPlacement from "./types/PopoverPlacement.js";
import PopoverVerticalAlign from "./types/PopoverVerticalAlign.js";
import PopoverHorizontalAlign from "./types/PopoverHorizontalAlign.js";
import { addOpenedPopover, removeOpenedPopover } from "./popup-utils/PopoverRegistry.js";
import PopoverResize from "./PopoverResize.js";

// Template
import PopoverTemplate from "./PopoverTemplate.js";
Expand Down Expand Up @@ -135,7 +136,7 @@ class Popover extends Popup {

/**
* Defines whether the component should close when
* clicking/tapping outside of the popover.
* clicking/tapping outside the popover.
* If enabled, it blocks any interaction with the background.
* @default false
* @public
Expand All @@ -161,6 +162,16 @@ class Popover extends Popup {
@property({ type: Boolean })
allowTargetOverlap = false;

/**
* Determines whether the component is resizable.
* **Note:** This property is effective only on desktop devices.
* @default false
* @public
* @since 2.18.0
*/
@property({ type: Boolean })
resizable = false;

/**
* Sets the X translation of the arrow
* @private
Expand Down Expand Up @@ -211,12 +222,19 @@ class Popover extends Popup {
_width?: string;
_height?: string;

_popoverResize: PopoverResize;

_initialWidth?: string;
_initialHeight?: string;

static get VIEWPORT_MARGIN() {
return 10; // px
}

constructor() {
super();

this._popoverResize = new PopoverResize(this);
}

/**
Expand Down Expand Up @@ -262,11 +280,25 @@ class Popover extends Popup {
return;
}

this._initialWidth = this.style.width;
this._initialHeight = this.style.height;

this._openerRect = opener.getBoundingClientRect();

await super.openPopup();
}

closePopup(escPressed = false, preventRegistryUpdate = false, preventFocusRestore = false) : void {
Object.assign(this.style, {
width: this._initialWidth,
height: this._initialHeight,
});

this._popoverResize.reset();

super.closePopup(escPressed, preventRegistryUpdate, preventFocusRestore);
}

isOpenerClicked(e: MouseEvent) {
const target = e.target as HTMLElement;
const opener = this.getOpenerHTMLElement(this.opener);
Expand All @@ -286,6 +318,17 @@ class Popover extends Popup {
return e.composedPath().indexOf(opener) > -1;
}

isClicked(e: MouseEvent) {
if (this._showResizeHandle) {
const resizeHandle = this.shadowRoot!.querySelector(".ui5-popover-resize-handle");
if (resizeHandle === e.composedPath()[0]) {
return true;
}
}

return isClickInRect(e, this.getBoundingClientRect());
}

/**
* Override for the _addOpenedPopup hook, which would otherwise just call addOpenedPopup(this)
* @private
Expand Down Expand Up @@ -378,6 +421,10 @@ class Popover extends Popup {
}
}

get _viewportMargin() {
return Popover.VIEWPORT_MARGIN;
}

reposition() {
this._show();
}
Expand Down Expand Up @@ -462,6 +509,10 @@ class Popover extends Popup {
left: `${left}px`,
});

if (this._popoverResize.isResized) {
return;
}

if (this.horizontalAlign === PopoverHorizontalAlign.Stretch && this._width) {
this.style.width = this._width;
}
Expand Down Expand Up @@ -553,12 +604,14 @@ class Popover extends Popup {
const isVertical = actualPlacement === PopoverActualPlacement.Top
|| actualPlacement === PopoverActualPlacement.Bottom;

if (this.horizontalAlign === PopoverHorizontalAlign.Stretch && isVertical) {
popoverSize.width = targetRect.width;
this._width = `${targetRect.width}px`;
} else if (this.verticalAlign === PopoverVerticalAlign.Stretch && !isVertical) {
popoverSize.height = targetRect.height;
this._height = `${targetRect.height}px`;
if (!this._popoverResize.isResized) {
if (this.horizontalAlign === PopoverHorizontalAlign.Stretch && isVertical) {
popoverSize.width = targetRect.width;
this._width = `${targetRect.width}px`;
} else if (this.verticalAlign === PopoverVerticalAlign.Stretch && !isVertical) {
popoverSize.height = targetRect.height;
this._height = `${targetRect.height}px`;
}
}

const arrowOffset = this.hideArrow ? 0 : ARROW_SIZE;
Expand Down Expand Up @@ -790,6 +843,7 @@ class Popover extends Popup {
case PopoverActualHorizontalAlign.Center:
case PopoverActualHorizontalAlign.Stretch:
left = targetRect.left - (popoverSize.width - targetRect.width) / 2;
left = this._popoverResize.getCorrectedLeft(left);
break;
case PopoverActualHorizontalAlign.Left:
left = targetRect.left;
Expand All @@ -809,6 +863,7 @@ class Popover extends Popup {
case PopoverVerticalAlign.Center:
case PopoverVerticalAlign.Stretch:
top = targetRect.top - (popoverSize.height - targetRect.height) / 2;
top = this._popoverResize.getCorrectedTop(top);
break;
case PopoverVerticalAlign.Top:
top = targetRect.top;
Expand Down Expand Up @@ -849,6 +904,11 @@ class Popover extends Popup {
get classes() {
const allClasses = super.classes;
allClasses.root["ui5-popover-root"] = true;
allClasses.root["ui5-popover-rtl"] = this.isRtl;

if (this.resizable) {
this._popoverResize.setCorrectResizeHandleClass(allClasses);
}

return allClasses;
}
Expand Down Expand Up @@ -884,6 +944,14 @@ class Popover extends Popup {
return PopoverActualHorizontalAlign.Center;
}
}

get _showResizeHandle() {
return this.resizable && this.onDesktop;
}

_onResizeMouseDown(e: MouseEvent) {
this._popoverResize.onResizeMouseDown(e);
}
}

const instanceOfPopover = (object: any): object is Popover => {
Expand All @@ -894,4 +962,4 @@ Popover.define();

export default Popover;

export { instanceOfPopover };
export { instanceOfPopover, PopoverActualPlacement, PopoverActualHorizontalAlign };
Loading
Loading