Skip to content

Commit

Permalink
fix: remove the disabled attribute from input, to pop up keyboard on …
Browse files Browse the repository at this point in the history
…iOS devices (#287)
  • Loading branch information
razonyang authored Feb 16, 2025
1 parent 6562ab4 commit 73d8de2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions assets/search/js/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class Form {
<div class="search-input-group">
<span class="search-input-icon">${params.icons['search']}</span>
<span class="search-spinner">${params.icons['spinner']}</span>
<input type="search" name="q" class="search-input search-form-control" placeholder="${translate('input_placeholder')}" autocomplete="off" disabled/>
<input type="search" name="q" class="search-input search-form-control" placeholder="${translate('input_placeholder')}" autocomplete="off" />
<button class="search-reset-button disabled" type="reset">${params.icons['reset']}</button>
</div>
<button class="search-modal-close" type="button">${translate('cancel')}</button>
Expand Down Expand Up @@ -154,6 +154,8 @@ export default class Form {

private initialized = false

private engineInitialized = false

// Initialize the form after rendering.
init() {
if (this.initialized) {
Expand Down Expand Up @@ -213,18 +215,17 @@ export default class Form {
this.spinner.show()
engine.init().then(() => {
this.renderPanel()
}).then(() => {
this.input.removeAttribute('disabled')
}).catch((err) => {
this.input.setAttribute('disabled', '')
this.input.value = translate('index_fails')
throw err
}).then(() => {
if (!this.modal) {
this.fillInputByURL()
this.submit()
}
this.engineInitialized = true
}).finally(() => {
this.focus()
this.spinner.hide()
})

Expand Down Expand Up @@ -282,6 +283,11 @@ ${this.renderTaxonomies()}
}

private fillInputByURL() {
// If the input is not empty, do nothing.
if (this.input.value.trim() !== '') {
return
}

const params = new URLSearchParams(location.search)
const q = params.get('q')
if (q) {
Expand All @@ -301,6 +307,11 @@ ${this.renderTaxonomies()}
const query = this.getQuery()
this.updatePage(query)

// Do not search if the engine is not initialized.
if (!this.engineInitialized) {
return
}

const sorting = this.getSorting()
const lang = this.getLanguage()
const years = this.getYears()
Expand Down

0 comments on commit 73d8de2

Please sign in to comment.