Skip to content

Commit df7002f

Browse files
authored
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! :)
2 parents f06b75d + 351cc1f commit df7002f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: src/librustdoc/html/static/js/search.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5318,8 +5318,9 @@ function registerSearchEvents() {
53185318

53195319
// @ts-expect-error
53205320
searchState.input.addEventListener("blur", () => {
5321-
// @ts-expect-error
5322-
searchState.input.placeholder = searchState.input.origPlaceholder;
5321+
if (window.searchState.input) {
5322+
window.searchState.input.placeholder = window.searchState.origPlaceholder;
5323+
}
53235324
});
53245325

53255326
// Push and pop states are used to add search results to the browser

0 commit comments

Comments
 (0)