From 919d4e62b8e464e4babd76f6fd13c944daee3af6 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 2 Dec 2019 10:04:40 +0100 Subject: Fix keyboard and focus handling for UploadInput component --- .../main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl') diff --git a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt index 932bd444..ecdbf1b8 100644 --- a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt +++ b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt @@ -181,6 +181,10 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla @Suppress("UnsafeCastFromDynamic") override fun afterInsert(node: VNode) { getElementJQueryD()?.fileinput(getSettingsObj()) + getElementJQuery()?.parent()?.parent()?.parent()?.find("div.kv-fileinput-caption")?.removeAttr("tabindex") + getElementJQuery()?.parent()?.parent()?.parent()?.find("input.file-caption-name")?.attr("tabindex", "-1") + getElementJQuery()?.parent()?.parent()?.parent()?.find("button.fileinput-remove")?.removeAttr("tabindex") + getElementJQuery()?.parent()?.parent()?.parent()?.find("div.btn-file")?.removeAttr("tabindex") if (uploadUrl != null) { this.getElementJQuery()?.on("fileselect") { e, _ -> this.dispatchEvent("fileSelectUpload", obj { detail = e }) @@ -201,6 +205,12 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla return@lambda null } } + this.getElementJQuery()?.on("focus") { _, _ -> + getElementJQuery()?.parent()?.parent()?.parent()?.addClass("kv-focus") + } + this.getElementJQuery()?.on("blur") { _, _ -> + getElementJQuery()?.parent()?.parent()?.parent()?.removeClass("kv-focus") + } } override fun afterDestroy() { -- cgit