mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -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 {
|
||||
connectedCallback () {
|
||||
this.button.addEventListener('click', (event) => {
|
||||
if (!this.input.value && document.activeElement !== this.input) {
|
||||
event.preventDefault()
|
||||
|
||||
this.input.focus()
|
||||
}
|
||||
})
|
||||
this.addEventListener('click', this.onClick)
|
||||
|
||||
document.addEventListener('turbo:before-cache', this.onBeforeCache)
|
||||
|
||||
if (this.input.value) {
|
||||
if (this.input?.value) {
|
||||
this.input.focus()
|
||||
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)
|
||||
}
|
||||
|
||||
onClick = (event) => {
|
||||
if (!event.target.closest('button')) return
|
||||
|
||||
if (!this.input.value && document.activeElement !== this.input) {
|
||||
event.preventDefault()
|
||||
|
||||
this.input.focus()
|
||||
}
|
||||
}
|
||||
|
||||
onBeforeCache = () => {
|
||||
this.input.value = this.input.getAttribute('value') || ''
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user