1
Fork 0

Rollup merge of #137055 - fmease:rustdoc-js-fix-input-placeholder-logic, r=notriddle

rustdoc: Properly restore search input placeholder

Fix the search input placeholder literally getting set to the string *undefined* on blur/defocus.
This was caused by us trying to access an undefined property in the event listener.
To prevent this from regressing again, stop typescript from ignoring the relevant site.

Steps to reproduce the bug fixed in this PR:

1. Focus the search input field by clicking on it and clear the input if necessary
2. Blur/defocus it by clicking somewhere outside of it

---

First bug that would've been caught by TSC if we had had it earlier! Type (quasi-)safety, ahoy! :)
This commit is contained in:
Matthias Krüger 2025-02-15 20:15:00 +01:00 committed by GitHub
commit df7002fac0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5318,8 +5318,9 @@ function registerSearchEvents() {
// @ts-expect-error
searchState.input.addEventListener("blur", () => {
// @ts-expect-error
searchState.input.placeholder = searchState.input.origPlaceholder;
if (window.searchState.input) {
window.searchState.input.placeholder = window.searchState.origPlaceholder;
}
});
// Push and pop states are used to add search results to the browser