aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Link.kt12
-rw-r--r--src/main/resources/css/style.css4
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt2
4 files changed, 14 insertions, 6 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 4622ceca..8a37cf6c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -190,7 +190,7 @@ open class DropDown(
DD.SEPARATOR.option -> Separator()
DD.DISABLED.option -> {
val tag = Tag(TAG.LI, classes = setOf("disabled"))
- tag.add(Link(it.first, "javascript:void(0)"))
+ tag.add(Link(it.first))
tag
}
else -> Link(it.first, it.second)
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
index 50a45047..d1cf9a12 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
@@ -39,7 +39,7 @@ import pl.treksoft.kvision.panel.SimplePanel
* @param classes a set of CSS class names
*/
open class Link(
- label: String, url: String, icon: String? = null, image: ResString? = null,
+ label: String, url: String? = null, icon: String? = null, image: ResString? = null,
classes: Set<String> = setOf()
) : SimplePanel(classes) {
/**
@@ -65,7 +65,11 @@ open class Link(
}
override fun getSnAttrs(): List<StringPair> {
- return super.getSnAttrs() + ("href" to url)
+ val pr = super.getSnAttrs().toMutableList()
+ url?.let {
+ pr.add("href" to it)
+ }
+ return pr
}
companion object {
@@ -75,7 +79,7 @@ open class Link(
* It takes the same parameters as the constructor of the built component.
*/
fun Container.link(
- label: String, url: String, icon: String? = null, image: ResString? = null,
+ label: String, url: String? = null, icon: String? = null, image: ResString? = null,
classes: Set<String> = setOf(), init: (Link.() -> Unit)? = null
): Link {
val link = Link(label, url, icon, image, classes).apply { init?.invoke(this) }
@@ -92,7 +96,7 @@ open class Link(
label: String, icon: String? = null, image: ResString? = null,
classes: Set<String> = setOf(), init: (Link.() -> Unit)? = null
): Link {
- val link = Link(label, "javascript:void(0)", icon, image, classes).apply { init?.invoke(this) }
+ val link = Link(label, null, icon, image, classes).apply { init?.invoke(this) }
val tag = Tag(TAG.LI, classes = setOf("disabled"))
tag.add(link)
this.add(tag)
diff --git a/src/main/resources/css/style.css b/src/main/resources/css/style.css
index 9df9960b..d6242ddd 100644
--- a/src/main/resources/css/style.css
+++ b/src/main/resources/css/style.css
@@ -131,3 +131,7 @@ trix-toolbar .trix-button-group {
.kv-window .modal-header .modal-title {
white-space: nowrap;
}
+
+ul.dropdown-menu li a {
+ cursor: pointer;
+}
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
index a04b25b0..9aa088fd 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
@@ -109,7 +109,7 @@ class DropDownSpec : DomSpec {
val element = document.getElementById("test")
val id = dd.button.id
assertEqualsHtml(
- "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" role=\"button\" href=\"#\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"disabled\"><a href=\"javascript:void(0)\">abc</a></li></ul></div>",
+ "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" role=\"button\" href=\"#\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"disabled\"><a>abc</a></li></ul></div>",
element?.innerHTML,
"Should render correct drop down"
)