-
Notifications
You must be signed in to change notification settings - Fork 80
fix(dropdown-group): fix error caused by early removal #11612
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
Merged
jcfranco
merged 1 commit into
dev
from
jcfranco/10028-fix-dropdown-group-early-disconnect-error
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,6 @@ export class DropdownGroup extends LitElement { | |
|
||
// #region Private Properties | ||
|
||
/** position of group within a dropdown */ | ||
private groupPosition: number; | ||
|
||
private mutationObserver = createObserver("mutation", () => this.updateItems()); | ||
|
||
/** the requested group */ | ||
|
@@ -45,6 +42,13 @@ export class DropdownGroup extends LitElement { | |
/** Specifies and displays a group title. */ | ||
@property({ reflect: true }) groupTitle: string; | ||
|
||
/** | ||
* The position of the group in the dropdown menu. | ||
* | ||
* @internal | ||
*/ | ||
@property() position: number = -1; | ||
|
||
/** | ||
* Specifies the size of the component inherited from the parent `calcite-dropdown`, defaults to `m`. | ||
* | ||
|
@@ -87,10 +91,6 @@ export class DropdownGroup extends LitElement { | |
this.mutationObserver?.observe(this.el, { childList: true }); | ||
} | ||
|
||
load(): void { | ||
this.groupPosition = this.getGroupPosition(); | ||
} | ||
|
||
override willUpdate(changes: PropertyValues<this>): void { | ||
/* TODO: [MIGRATION] First time Lit calls willUpdate(), changes will include not just properties provided by the user, but also any default values your component set. | ||
To account for this semantics change, the checks for (this.hasUpdated || value != defaultValue) was added in this method | ||
|
@@ -123,13 +123,6 @@ export class DropdownGroup extends LitElement { | |
); | ||
} | ||
|
||
private getGroupPosition(): number { | ||
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. yay no more looking up the dom! |
||
return Array.prototype.indexOf.call( | ||
this.el.parentElement.querySelectorAll("calcite-dropdown-group"), | ||
this.el, | ||
); | ||
} | ||
|
||
// #endregion | ||
|
||
// #region Rendering | ||
|
@@ -142,7 +135,7 @@ export class DropdownGroup extends LitElement { | |
) : null; | ||
|
||
const dropdownSeparator = | ||
this.groupPosition > 0 ? <div class={CSS.separator} role="separator" /> : null; | ||
this.position > 0 ? <div class={CSS.separator} role="separator" /> : null; | ||
/* TODO: [MIGRATION] This used <Host> before. In Stencil, <Host> props overwrite user-provided props. If you don't wish to overwrite user-values, replace "=" here with "??=" */ | ||
this.el.ariaLabel = this.groupTitle; | ||
/* TODO: [MIGRATION] This used <Host> before. In Stencil, <Host> props overwrite user-provided props. If you don't wish to overwrite user-values, replace "=" here with "??=" */ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,7 +311,7 @@ export class Dropdown | |
|
||
private handlePropsChange(): void { | ||
this.updateItems(); | ||
this.updateGroupScale(); | ||
this.updateGroupProps(); | ||
} | ||
|
||
private closeCalciteDropdownOnClick(event: MouseEvent): void { | ||
|
@@ -431,11 +431,14 @@ export class Dropdown | |
this.groups = groups; | ||
|
||
this.updateItems(); | ||
this.updateGroupScale(); | ||
this.updateGroupProps(); | ||
} | ||
|
||
private updateGroupScale(): void { | ||
this.groups?.forEach((group) => (group.scale = this.scale)); | ||
private updateGroupProps(): void { | ||
this.groups.forEach((group, index) => { | ||
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. Nice, this is much better having the dropdown set its group index. |
||
group.scale = this.scale; | ||
group.position = index; | ||
}); | ||
} | ||
|
||
private resizeObserverCallback(entries: ResizeObserverEntry[]): void { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should there be a
defaults
test to test for-1
now that its not undefined by default?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.
We can skip it since it's an implementation detail.