-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add open-state markers for nested popover parents #2967
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
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,7 +178,11 @@ export class PopoverDesktop extends PopoverAbstract { | |
| */ | ||
| protected override showNestedItems(item: PopoverItem): void { | ||
| if (this.nestedPopover !== null && this.nestedPopover !== undefined) { | ||
| return; | ||
| if (this.nestedPopoverTriggerItem === item) { | ||
| return; | ||
| } | ||
|
|
||
| this.destroyNestedPopoverIfExists(); | ||
| } | ||
|
|
||
| this.nestedPopoverTriggerItem = item; | ||
|
|
@@ -232,6 +236,8 @@ export class PopoverDesktop extends PopoverAbstract { | |
| * Destroys existing nested popover | ||
| */ | ||
| protected destroyNestedPopoverIfExists(): void { | ||
| this.clearOpenedState(); | ||
|
|
||
| if (this.nestedPopover === undefined || this.nestedPopover === null) { | ||
| return; | ||
| } | ||
|
|
@@ -271,6 +277,7 @@ export class PopoverDesktop extends PopoverAbstract { | |
|
|
||
| const nestedPopoverEl = this.nestedPopover.getElement(); | ||
|
|
||
| this.clearOpenedState(); | ||
| this.nodes.popover.appendChild(nestedPopoverEl); | ||
|
|
||
| this.setTriggerItemPosition(nestedPopoverEl, item); | ||
|
|
@@ -281,9 +288,28 @@ export class PopoverDesktop extends PopoverAbstract { | |
| this.nestedPopover.show(); | ||
| this.flipper?.deactivate(); | ||
|
|
||
| this.clearOpenedState(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why it is called twice in this context? |
||
| const triggerEl = item.getElement(); | ||
| if (triggerEl) { | ||
| triggerEl.dataset.itemOpened = 'true'; | ||
| triggerEl.setAttribute('aria-expanded', 'true'); | ||
| } | ||
|
Comment on lines
+293
to
+296
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jsdoc is required here |
||
|
|
||
| return this.nestedPopover; | ||
| } | ||
|
|
||
| /** | ||
| * Clears open-state markers from all popover items | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSDoc repeats function name. Please, describe why we need this method instead. |
||
| */ | ||
| private clearOpenedState(): void { | ||
| this.nodes.popover | ||
| ?.querySelectorAll<HTMLElement>('.ce-popover-item[data-item-opened]') | ||
| .forEach((el) => { | ||
| delete el.dataset.itemOpened; | ||
| el.removeAttribute('aria-expanded'); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Checks if popover should be opened bottom. | ||
| * It should happen when there is enough space below or not enough space above | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, add a jsdoc describing this statement