Track active gallery element

pull/4625/head
awsr 2026-02-06 00:44:48 -08:00
parent 171ead0fa2
commit f84cb6ac64
No known key found for this signature in database
1 changed files with 10 additions and 0 deletions

View File

@ -315,6 +315,8 @@ class SimpleFunctionQueue {
class GalleryFolder extends HTMLElement {
static folders = new Set();
/** @type {GalleryFolder | null} */
static #active = null;
constructor(folder) {
super();
@ -352,10 +354,18 @@ class GalleryFolder extends HTMLElement {
await Promise.resolve(); // Wait for other microtasks (such as element moving)
if (this.isConnected) return;
GalleryFolder.folders.delete(this);
if (GalleryFolder.#active === this) {
GalleryFolder.#active = null;
}
}
static getActive() {
return GalleryFolder.#active;
}
updateSelected() {
this.div.classList.add('gallery-folder-selected');
GalleryFolder.#active = this;
for (const folder of GalleryFolder.folders) {
if (folder !== this) {
folder.div.classList.remove('gallery-folder-selected');