https://kotlinlang.org logo
#kvision
Title
# kvision
j

Jörg Rade

11/11/2021, 11:20 AM
There is class kv-tab-close but no kv-tab-icon. Would this be the way to go?
r

Robert Jaros

11/11/2021, 12:00 PM
Tab icon is not a component. It's just a part of the
Link
component inside the tab.
If you need to bind some handler to the click event on the icon, you could use probably use native listener.
Copy code
tab("Tab name", "fas fa-check") {
	div("Tab content")
	addAfterInsertHook {
		getElement()?.unsafeCast<Element>()?.querySelector("i")?.addEventListener("click", {
			console.log("icon clicked")
		})
	}
}
👍 1
Are we still talking about opening menu when tab icon is clicked?
j

Jörg Rade

04/08/2022, 9:20 AM
Yes, exactly.
r

Robert Jaros

04/08/2022, 8:27 PM
You can try this:
Copy code
val contextMenu = ContextMenu {
                cmLink("First item", "#!/first")
                cmLink("Second item", "#!/second")
                // you can generate links from buildOjectMenu array
            }
            tabPanel {
                tab("A tab", "fas fa-times") {
                    div("Some content")
                    addAfterInsertHook {
                        getElement()?.unsafeCast<Element>()?.querySelector("i")?.addEventListener("click", {
                            it.stopPropagation()
                            contextMenu.positionMenu(it.unsafeCast<MouseEvent>())
                        })
                    }
                }
            }
j

Jörg Rade

04/09/2022, 7:12 AM
💪 🙏