Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove the disabled attribute from input, to pop up keyboard on iOS devices #287

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading