fix search modal race condition and add 304 support for images

Route all search modal open/close through the JS hook via custom DOM
events so the _closing flag is always correctly managed. Prevents the
modal flashing back after Escape when a search response is in flight.

Add If-None-Match / 304 Not Modified handling to the image controller
so browsers don't re-download images on revalidation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-13 16:21:51 +00:00
parent 994f6fe0d6
commit 44933acebb
3 changed files with 98 additions and 74 deletions

View File

@@ -341,6 +341,9 @@ const SearchModal = {
}
document.addEventListener("keydown", this._globalKeydown)
this.el.addEventListener("open-search", () => this.open())
this.el.addEventListener("close-search", () => this.close())
this.el.addEventListener("keydown", (e) => {
if (!this.isOpen()) return
@@ -370,6 +373,7 @@ const SearchModal = {
},
updated() {
if (this._closing) this.el.style.display = "none"
this.selectedIndex = -1
this.updateHighlight()
},
@@ -379,6 +383,7 @@ const SearchModal = {
},
open() {
this._closing = false
this.el.style.display = "flex"
this.pushEvent("open_search", {})
const input = this.el.querySelector("#search-input")
@@ -391,6 +396,7 @@ const SearchModal = {
},
close() {
this._closing = true
this.el.style.display = "none"
this.pushEvent("clear_search", {})
this.selectedIndex = -1