Skip to content

Commit

Permalink
ContextMenu: improve compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Aug 7, 2024
1 parent 4ffe24a commit fa348a7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,28 @@ internal fun DynaNodeGroup.contextMenuTestbatch() {
expect(2) { called }
}

test("setOpened(true) succeeds on null item") {
var called = 0
lateinit var cm: GridContextMenu<String>
UI.getCurrent().grid<String> {
cm = gridContextMenu {
item("click me")
setDynamicContentHandler { item ->
expect(null) { item }
expect(0) { called }
called = 1
true
}
}
}
cm.addGridContextMenuOpenedListener { e ->
expect(1) { called }
called = 2
}
cm.setOpened(true, null)
expect(2) { called }
}

test("setOpened(false) fires GridContextMenuOpenedEvent") {
var called = false
lateinit var cm: GridContextMenu<String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ private val __ContextMenuBase_onBeforeOpenMenu: Method by lazy {

private fun ContextMenuBase<*, *, *>.invokeOnBeforeOpenMenu(itemKey: String?, columnId: String?): Boolean {
val json = Json.createObject().apply {
if (itemKey != null) put("key", itemKey)
if (columnId != null) put("columnId", columnId)
put("key", itemKey ?: "")
put("columnId", columnId ?: "")
}
val obj = __ContextMenuBase_onBeforeOpenMenu.invoke(this, json) as Boolean
return obj
Expand Down

0 comments on commit fa348a7

Please sign in to comment.