Skip to content

Conversation

@devketanpro
Copy link
Member

@devketanpro devketanpro commented Oct 13, 2025

SDBELGA-995

Purpose:
Rework the datepicker popover, so it is positioned correctly, and it's content isn't cut off at the bottom.

@devketanpro devketanpro requested a review from thecalcc October 13, 2025 02:51
@thecalcc
Copy link
Contributor

why did we do the padding change? Could you post before/after screenshots

@devketanpro
Copy link
Member Author

Before screenshot:
image

After screenshot:
image

@devketanpro
Copy link
Member Author

why did we do the padding change? Could you post before/after screenshots

The padding change was made to improve the spacing and overall layout consistency.

Copy link
Member

@tomaskikutis tomaskikutis left a comment

Choose a reason for hiding this comment

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

That's not fixing the root cause of the issue. It's positioning code of date picker that should be improved.

@thecalcc
Copy link
Contributor

Tomas is correct, fix should be in UI framework, we have some positioning code already there for e.g. WithPopover check if you can reuse that so we have dynamic positioning, thus is space on the bottom is not enough to display the whole popover auto positioner puts it on the top or other positions.

if (value) {
$popupWrapper.offset(popupService.position(260, 270, element));
scope.$broadcast('datepicker.focus');
$timeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need $timeout from angular? you can use setTimeout probably.

Also why is the timeout needed in the first place? Are you waiting for the component to render first? Also can you drop the usage of this legacy $popupWrapper?

Could you instead of making a legacy hack replace the whole component with a new one from UI framework?

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking the same that it would probably be easier to connect date picker from ui-framework rather than correct positioning code which is not the easiest thing. But if this patch works I'm fine with the existing solution.

@thecalcc thecalcc changed the title The date picker in search filter for created date is not complete [SDBELGA-995] The date picker in search filter is not positioned correctly [SDBELGA-995] Oct 15, 2025
if (value) {
$popupWrapper.offset(popupService.position(260, 270, element));
scope.$broadcast('datepicker.focus');
$timeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking the same that it would probably be easier to connect date picker from ui-framework rather than correct positioning code which is not the easiest thing. But if this patch works I'm fine with the existing solution.

Copy link
Contributor

@thecalcc thecalcc left a comment

Choose a reason for hiding this comment

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

let me know if you need help with the positioning

@devketanpro
Copy link
Member Author

image

// Get position of the active input element
const rect = element[0].getBoundingClientRect();

// Measure popup size (use defaults if not available)
Copy link
Contributor

Choose a reason for hiding this comment

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

why would it not be available? if it's not available why does popup get rendered?

let left = rect.left + scrollX;

// If not enough space below, open upward
// If not enough space below, open upward (keep margin so input is not overlapped)
Copy link
Contributor

@thecalcc thecalcc Oct 17, 2025

Choose a reason for hiding this comment

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

Could you make this comment better? "If there isn't enough space available below the input, position the popup above the input"

@devketanpro devketanpro requested a review from thecalcc October 27, 2025 10:40
Comment on lines +452 to +457
if (rect.bottom + popupHeight + TOLERANCE > viewportHeight && rect.top >= popupHeight + GAP + TOLERANCE) {
top = rect.top + scrollY - popupHeight - GAP;
} else if (rect.bottom + popupHeight + TOLERANCE > viewportHeight) {
// Neither side fits fully: clamp into viewport and prefer below.
top = Math.min(Math.max(scrollY + TOLERANCE, rect.bottom + scrollY + GAP), scrollY + viewportHeight - popupHeight - TOLERANCE);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

could you make the code here readable?

// We also re-run the positioning on the next frame and after a small
const MARGIN = 8;
const RECHECK_DELAY = 50;
if (!value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick - could you have this as an explicit check like value == null

const viewportWidth = window.innerWidth;
const scrollX = window.scrollX || window.pageXOffset;
const scrollY = window.scrollY || window.pageYOffset;
// Measure popup size (use sensible defaults if not available)
Copy link
Contributor

Choose a reason for hiding this comment

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

in my understanding, if the popup element is not available, this function shouldn't be called. if so, then we don't need fallback values. But if it's still running when popupEl is null, we should fix that first

Comment on lines +444 to +445
const inputHeight = rect.height || (element.outerHeight && element.outerHeight()) || 32;
const GAP = Math.max(8, Math.round(inputHeight));
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this? and not just rect.height

}
// Dynamic gap based on input height so popup doesn't cover the input.
const inputHeight = rect.height || (element.outerHeight && element.outerHeight()) || 32;
const GAP = Math.max(8, Math.round(inputHeight));
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not a gap, it's input height

@thecalcc
Copy link
Contributor

Closing in favour of #4994

@thecalcc thecalcc closed this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants