fix(auth): refresh home listings after login and auto-focus login input

This commit is contained in:
2026-02-04 17:11:44 +01:00
parent 220599944c
commit 50513da570
3 changed files with 19 additions and 3 deletions

View File

@@ -32,6 +32,12 @@ class AuthModal extends HTMLElement {
this.hidden = false
this.render()
document.body.style.overflow = 'hidden'
// Focus on input after render
requestAnimationFrame(() => {
const input = this.querySelector('#uuid')
if (input) input.focus()
})
}
hide() {

View File

@@ -299,14 +299,14 @@ style.textContent = /* css */`
position: absolute;
top: var(--space-sm);
left: var(--space-sm);
width: 28px;
height: 28px;
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
background: var(--color-bg);
border: none;
border-radius: var(--radius-sm);
border-radius: var(--radius-full);
box-shadow: var(--shadow-sm);
z-index: 2;
color: var(--color-text-muted);

View File

@@ -2,6 +2,7 @@ import { t, i18n } from '../../i18n.js'
import { listingsService } from '../../services/listings.js'
import { directus } from '../../services/directus.js'
import { locationsService } from '../../services/locations.js'
import { auth } from '../../services/auth.js'
import '../listing-card.js'
import '../skeleton-card.js'
import '../search-box.js'
@@ -38,6 +39,14 @@ class PageHome extends HTMLElement {
this.render()
this.setupEventListeners()
})
// Re-render listings on auth change to show owner badges
this.authUnsubscribe = auth.subscribe(() => {
const container = this.querySelector('#listings-container')
if (container) {
container.innerHTML = this.renderListings()
}
})
// Listen for URL changes (back/forward navigation)
window.addEventListener('hashchange', this.handleHashChange.bind(this))
@@ -45,6 +54,7 @@ class PageHome extends HTMLElement {
disconnectedCallback() {
if (this.unsubscribe) this.unsubscribe()
if (this.authUnsubscribe) this.authUnsubscribe()
window.removeEventListener('hashchange', this.handleHashChange.bind(this))
}