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

feat(popover-beta): Added popover-beta component #642

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

jason-evans-genesys
Copy link
Collaborator

@jason-evans-genesys jason-evans-genesys commented Oct 4, 2024

This PR came out of this other one: #627

TODO: add new UX token once UX finishes this ticket: https://inindca.atlassian.net/browse/GDS-2672

Using native popover-api with the popover-beta component. This has a breaking change which is requiring the for prop to be set.

✅ Closes: COMUI-1637

@jason-evans-genesys jason-evans-genesys self-assigned this Oct 4, 2024
Copy link

github-actions bot commented Oct 4, 2024

position: absolute;
top: 0;
left: 0;
z-index: var(--gse-semantic-zIndex-popover);
Copy link
Collaborator

@gavin-everett-genesys gavin-everett-genesys Oct 7, 2024

Choose a reason for hiding this comment

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

It looks by using the native api it adds the popover to the top layer. You can see this by scrolling the container in the example file the popover will appear over all the elements. Whereas in the stable gux-popover it utilises the z-index we set. I am not sure if we need this property anymore but we can maybe discuss in collab time.

From the docs : "Shows a popover element by adding it to the top layer."

https://developer.mozilla.org/en-US/docs/Web/API/Popover_API

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great catch. I'm seeing this in the docs too. I can bring it up during collab time.

this.forElement.popoverTargetAction = 'toggle';

if (this.isOpen) {
this.popupElement.showPopover();
Copy link
Collaborator

Choose a reason for hiding this comment

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

From reading through the docs the popupElement should have an attribute of popup for the showPopover to work but I could not find it.

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/showPopover

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's that the div that has a popover attribute on it should work to use the showPopover method.

Comment on lines +32 to +39
.gux-arrow {
position: absolute;
width: var(--gse-ui-popover-anchor-width);
height: var(--gse-ui-popover-anchor-height);

/* 4px padding leaves some space for the shadow to bleed into */
padding-bottom: 4px;
overflow: hidden;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont think this arrow is currently displaying.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking into this now.

left: 0;
z-index: var(--gse-semantic-zIndex-popover);
display: inline-block;
min-width: 280px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

is a token needed here ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great catch. I'll ask the UX team.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

UX said they will make a new token for this: https://inindca.atlassian.net/browse/GDS-2672

<popover
ref={(el: HTMLDivElement) => (this.popupElement = el)}
class={{
'gux-hidden': !this.isOpen,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this styling can be removed as its probably done via , showPopover and hidePopover I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So you're right that we don't need to control visibility anymore with css (I've removed the gux-hidden css for this component) but I'm having trouble checking if the popover is visible or not in this component's unit tests. Checking if gux-hidden is present or not makes it easy to test visibility for this component but let me know if you know of another way to check if the popover is visible or not in jest.

@jason-evans-genesys
Copy link
Collaborator Author

@daragh-king-genesys I got the popover to hide when you scroll outside of its context container so all good now: 090b604

<div id="popover-target">
Example Element
</div>
<gux-popover position="top" for="popover-target">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure that these tests are updated to test the gux-popover-beta component

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -215,6 +215,8 @@ export class GuxPopover {
componentDidLoad(): void {
if (this.isOpen) {
this.runUpdatePosition();
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this an unrelated change? It should be excluded from this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@katie-bobbe-genesys
Copy link
Collaborator

the feature branch is not building, I think because of a snapshot issue having to do with time zones. If you merge in main the feature branch should build

@jason-evans-genesys
Copy link
Collaborator Author

the feature branch is not building, I think because of a snapshot issue having to do with time zones. If you merge in main the feature branch should build

@katie-bobbe-genesys I merged main into this branch. Is the feature branch building for you now?

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