mirror of
https://github.com/docusealco/docuseal
synced 2026-11-12 23:42:33 -05:00
fix search button
This commit is contained in:
1 parent
56bba60d3f
commit
e7fd1e4006
1 file changed
+12
-8
@@ -1,16 +1,10 @@
|
|||||||
export default class extends HTMLElement {
|
export default class extends HTMLElement {
|
||||||
connectedCallback () {
|
connectedCallback () {
|
||||||
this.button.addEventListener('click', (event) => {
|
this.addEventListener('click', this.onClick)
|
||||||
if (!this.input.value && document.activeElement !== this.input) {
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
this.input.focus()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('turbo:before-cache', this.onBeforeCache)
|
document.addEventListener('turbo:before-cache', this.onBeforeCache)
|
||||||
|
|
||||||
if (this.input.value) {
|
if (this.input?.value) {
|
||||||
this.input.focus()
|
this.input.focus()
|
||||||
this.input.setSelectionRange(this.input.value.length, this.input.value.length)
|
this.input.setSelectionRange(this.input.value.length, this.input.value.length)
|
||||||
}
|
}
|
||||||
@@ -20,6 +14,16 @@ export default class extends HTMLElement {
|
|||||||
document.removeEventListener('turbo:before-cache', this.onBeforeCache)
|
document.removeEventListener('turbo:before-cache', this.onBeforeCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClick = (event) => {
|
||||||
|
if (!event.target.closest('button')) return
|
||||||
|
|
||||||
|
if (!this.input.value && document.activeElement !== this.input) {
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
this.input.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onBeforeCache = () => {
|
onBeforeCache = () => {
|
||||||
this.input.value = this.input.getAttribute('value') || ''
|
this.input.value = this.input.getAttribute('value') || ''
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user