There is class kv-tab-close but no kv-tab-icon. Wo...
# kvision
j
There is class kv-tab-close but no kv-tab-icon. Would this be the way to go?
r
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
Yes, exactly.
r
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
💪 🙏