mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
use :has selectors for search input
This commit is contained in:
1 parent
48d595ca81
commit
d05e125fa9
10 files changed
+26
-57
No files matched your search
@@ -1,18 +1,5 @@
|
||||
export default class extends HTMLElement {
|
||||
connectedCallback () {
|
||||
this.input.addEventListener('focus', () => {
|
||||
if (this.title) {
|
||||
this.titleContainer.classList.add('max-md:hidden')
|
||||
}
|
||||
})
|
||||
|
||||
this.input.addEventListener('blur', (e) => {
|
||||
if (this.title && !e.target.value) {
|
||||
this.title.classList.remove('hidden')
|
||||
this.titleContainer.classList.remove('max-md:hidden')
|
||||
}
|
||||
})
|
||||
|
||||
this.button.addEventListener('click', (event) => {
|
||||
if (!this.input.value && document.activeElement !== this.input) {
|
||||
event.preventDefault()
|
||||
@@ -30,30 +17,12 @@ export default class extends HTMLElement {
|
||||
|
||||
onBeforeCache = () => {
|
||||
this.input.value = this.input.getAttribute('value') || ''
|
||||
|
||||
if (this.title) {
|
||||
this.titleContainer.classList.remove('max-md:hidden')
|
||||
}
|
||||
}
|
||||
|
||||
get input () {
|
||||
return this.querySelector('input')
|
||||
}
|
||||
|
||||
get title () {
|
||||
return document.querySelector(this.dataset.title)
|
||||
}
|
||||
|
||||
get titleContainer () {
|
||||
const parent = this.title.parentElement
|
||||
|
||||
if (parent && !parent.contains(this)) {
|
||||
return parent
|
||||
}
|
||||
|
||||
return this.title
|
||||
}
|
||||
|
||||
get button () {
|
||||
return this.querySelector('button')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user