-
Notifications
You must be signed in to change notification settings - Fork 166
🐛 fix(Menu): outside-click functionality issues when activator is 'parent' #2397
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…rent'
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -215,8 +215,12 @@ export function convertToUnit (str: string | number | null | undefined, unit = ' | |||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export function getActivator(selector: string): HTMLElement | null { | ||||||||||||||||||||||||||||||||
if (selector.startsWith(activator_parent_prefix)) { | ||||||||||||||||||||||||||||||||
function is$ParentSelector(selector: string) { | ||||||||||||||||||||||||||||||||
return selector.startsWith(activator_parent_prefix); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
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. [nitpick] Adding documentation for get$ParentElement to clarify its behavior—especially that it returns null if no parent element is found—would improve maintainability.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||
export function get$ParentElement(selector: string): HTMLElement | null { | ||||||||||||||||||||||||||||||||
if (is$ParentSelector(selector)) { | ||||||||||||||||||||||||||||||||
const parentSelector = selector.replace(activator_parent_prefix, ""); | ||||||||||||||||||||||||||||||||
const parentElement = document.querySelector(parentSelector)?.parentElement; | ||||||||||||||||||||||||||||||||
if (!parentElement) { | ||||||||||||||||||||||||||||||||
|
@@ -229,9 +233,14 @@ export function getActivator(selector: string): HTMLElement | null { | |||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
return parentElement; | ||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||
return document.querySelector(selector); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
return null | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export function getActivator(selector: string): HTMLElement | null { | ||||||||||||||||||||||||||||||||
const parentElement = get$ParentElement(selector); | ||||||||||||||||||||||||||||||||
return parentElement || document.querySelector(selector); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export function isWindow(element: any | Window): element is Window { | ||||||||||||||||||||||||||||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
[nitpick] Consider caching the result of get$ParentElement(selector) when iterating over multiple excluded selectors to reduce redundant DOM queries if the excludedSelectors array grows in size.
Copilot uses AI. Check for mistakes.