Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ui5-popover): improve layouting, styling and positioning #779

Merged
merged 11 commits into from
Oct 1, 2019

Conversation

MapTo0
Copy link
Member

@MapTo0 MapTo0 commented Sep 17, 2019

FIXES: #776

  • Popover will no longer close when the browser is scrolled
    and its parent (opener) is visible in the viewport.

BREAKING CHANGE: stayOpenOnScroll is now removed

BREAKING CHANGE: stayOpenOnScroll is now removed

- Popover will no longer close when the browser is scrolled
and its parent (opener) is visible in the viewport.
@@ -0,0 +1,27 @@
import { isEscape } from "@ui5/webcomponents-base/dist/events/PseudoEvents.js";

let registry = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

new Set() will be easier, you can add/delete instances directly (no need to filter)

Copy link
Member Author

Choose a reason for hiding this comment

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

Set does not guarantee the order of pushed elements, therefore I decided to go for the list implementation

return [...registry];
};

document.addEventListener("keydown", event => {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO make this a separate function, export it and run it explicitly from outside.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, how are we sure this Esc is not related to some other element inside the popup?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not :D Any proposals how we can move forward with that interaction?

packages/main/src/Popover.hbs Outdated Show resolved Hide resolved
@@ -0,0 +1,112 @@
import { isClickInRect } from "./PopupUtils.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this file to a directory, try to keep the main only for components themselves

Copy link
Member Author

Choose a reason for hiding this comment

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

I made a directory popup-utils name proposals are welcome

packages/main/src/PopoverRegistry.js Outdated Show resolved Hide resolved
}

// remove top popovers from registry
Array(count).fill().forEach(() => { openedRegistry.pop(); });
Copy link
Contributor

Choose a reason for hiding this comment

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

cool

packages/main/src/Popup.js Outdated Show resolved Hide resolved
packages/main/src/Popup.js Outdated Show resolved Hide resolved
packages/main/src/PopupUtils.js Outdated Show resolved Hide resolved
- move utils to popup-utils folder
- fix Vladi's initial comments
addOpenedPopup(instance);
openedRegistry.push(instance);

attachScrollHandler(instance);
Copy link
Member

Choose a reason for hiding this comment

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

just to clarify why we need to attach scroll handler per instance + global scroll handler

Copy link
Member Author

@MapTo0 MapTo0 Sep 24, 2019

Choose a reason for hiding this comment

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

the scrooll event does not bubble outside the shadowroot => globoal handler will not be called. Therefore we need a scroll handler to each instance which should reposition all opened popovers on the page (this is because we need to handle the usa case of having nested scrollable popovers)

const rect = domRef.getBoundingClientRect();
let x,
y;
addOpenedPopover(this);
Copy link
Member

Choose a reason for hiding this comment

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

Two lines above there is reposition() called, and addOpenedPopover(this) itself will call reposition() (though runUpdateInterval). Is this intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to call it synchronously so I can be sure that onbefore / after open will be called in the correct order.

@MapTo0 MapTo0 changed the title wip: ui5-popover refactoring refactor(ui5-popover): improve layouting, styling and positioning Sep 26, 2019
packages/main/src/themes/Popover.css Outdated Show resolved Hide resolved
packages/main/src/themes/Popover.css Outdated Show resolved Hide resolved
@MapTo0 MapTo0 merged commit 1d377ba into master Oct 1, 2019
@MapTo0 MapTo0 deleted the popover-refactoring branch October 1, 2019 13:38
ilhan007 added a commit that referenced this pull request Feb 9, 2022
The `stayOpenOnScroll` private property has been removed from the Popover long time ago with the PR
#779
ilhan007 added a commit that referenced this pull request Feb 9, 2022
The `stayOpenOnScroll` private property has been removed from the Popover long time ago with the PR
#779
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.

[Popover] - InputSuggestionItems in Popover don't show correctly
4 participants