-
Notifications
You must be signed in to change notification settings - Fork 85
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
Fix "Context menu on desktop shows incorrect items after the second showing" #1693
Conversation
…howing" Fixes https://youtrack.jetbrains.com/issue/CMP-7083/Context-menu-on-desktop-shows-incorrect-items-after-second-showing The issue was that after the first click we remembered context items, but they are constructed dynamically depending on the selected text. ## Testing - the snippet from the issue - a new unit test ## Release Notes ### Fixes - Desktop - Fix "Context menu on desktop shows incorrect items after the second showing"
|
||
internal val allItemsSeq: Sequence<ContextMenuItem> | ||
private val allItemsSeq: Sequence<ContextMenuItem> |
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.
Not really related to the change in this PR, but why do we need a sequence here? We could do the same with
internal val allItems: List<ContextMenuItem>
get() = buildList {
var current: ContextMenuData? = this@ContextMenuData
while (current != null) {
addAll(current.items())
current = current.next
}
}
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.
Your code is better
val Current get() = overriddenCurrent ?: _current | ||
|
||
@VisibleForTesting | ||
fun withOverriddenCurrent(newCurrent: DesktopPlatform, body: () -> Unit) { |
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.
Not crucial, but such functions are more useful if they're inline
, and return what body
returns.
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.
Done
Fixes https://youtrack.jetbrains.com/issue/CMP-7083/Context-menu-on-desktop-shows-incorrect-items-after-second-showing
The issue was that after the first click we remembered context items, but they are constructed dynamically depending on the selected text.
Testing
Release Notes
Fixes - Desktop