fix(wizard): z-index dropdown barrio + texto cortado opciones

Issue A: barrio-autocomplete-list cambia a position:fixed + getBoundingClientRect()
para escapar el overflow-y:auto de wizard-answer-area que clippeaba el dropdown.
z-index: 20 → 30 (clearear sticky topbar/bottombar z-index:10 en stacking context raíz).
Listener de scroll cierra el dropdown si el contenedor scrollea.

Issue B: wizard-answer-area max-height 360px → 480px (desktop) / 320px → 400px (mobile)
para mostrar ~8 opciones completas. .wizard-answer-area.has-overflow { padding-bottom: 44px }
asegura que el fade ::after (28px) cubre espacio vacío, no texto de opción.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
markosbenitez
2026-06-26 20:03:09 -03:00
parent 3ec5da0e54
commit 6e9ad89f7b
2 changed files with 32 additions and 9 deletions

View File

@@ -292,10 +292,9 @@ body {
/* ── Barrio autocomplete ── */ /* ── Barrio autocomplete ── */
.barrio-autocomplete-wrapper { position: relative; } .barrio-autocomplete-wrapper { position: relative; }
.barrio-autocomplete-list { .barrio-autocomplete-list {
position: absolute; /* position: fixed + top/left/width set by JS via getBoundingClientRect()
top: calc(100% + 4px); so the list escapes any overflow:auto ancestor (wizard-answer-area) */
left: 0; position: fixed;
right: 0;
background: var(--color-surface); background: var(--color-surface);
border: 1.5px solid var(--color-border-focus); border: 1.5px solid var(--color-border-focus);
border-radius: var(--radius); border-radius: var(--radius);
@@ -305,7 +304,7 @@ body {
padding: 4px 0; padding: 4px 0;
max-height: 220px; max-height: 220px;
overflow-y: auto; overflow-y: auto;
z-index: 20; z-index: 30;
} }
.barrio-autocomplete-item { .barrio-autocomplete-item {
padding: 9px 12px; padding: 9px 12px;
@@ -629,10 +628,11 @@ body {
.wizard-answer-area { .wizard-answer-area {
flex: 0 1 auto; flex: 0 1 auto;
min-height: 0; min-height: 0;
max-height: 360px; max-height: 480px;
overflow-y: auto; overflow-y: auto;
padding-bottom: 8px; padding-bottom: 8px;
} }
.wizard-answer-area.has-overflow { padding-bottom: 44px; }
/* El fade SOLO se pinta cuando .wizard-answer-area mide overflow real /* El fade SOLO se pinta cuando .wizard-answer-area mide overflow real
(clase has-overflow agregada por JS — ver wizard-form.tsx). CSS no tiene (clase has-overflow agregada por JS — ver wizard-form.tsx). CSS no tiene
forma de detectar scrollHeight > clientHeight por sí solo: un ::after forma de detectar scrollHeight > clientHeight por sí solo: un ::after
@@ -672,7 +672,7 @@ body {
@media (max-width: 480px) { @media (max-width: 480px) {
.wizard-prompt-text { font-size: 1.1875rem; } .wizard-prompt-text { font-size: 1.1875rem; }
.wizard-section-title { font-size: 1.5rem; } .wizard-section-title { font-size: 1.5rem; }
.wizard-answer-area { max-height: 320px; } .wizard-answer-area { max-height: 400px; }
} }
/* ── Loading skeleton ── */ /* ── Loading skeleton ── */

View File

@@ -1,5 +1,5 @@
'use client' 'use client'
import { useState, useEffect, useRef, type ReactNode } from 'react' import { useState, useEffect, useRef, type CSSProperties, type ReactNode } from 'react'
type GeoData = Record<string, Record<string, string[]>> type GeoData = Record<string, Record<string, string[]>>
@@ -27,6 +27,8 @@ export function BarrioAutocompleteField({
const [geoData, setGeoData] = useState<GeoData | null>(null) const [geoData, setGeoData] = useState<GeoData | null>(null)
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
const [activeIdx, setActiveIdx] = useState(-1) const [activeIdx, setActiveIdx] = useState(-1)
const [dropdownStyle, setDropdownStyle] = useState<CSSProperties>({})
const inputRef = useRef<HTMLInputElement>(null)
useEffect(() => { useEffect(() => {
fetch('/data/geo_paraguay_full.json') fetch('/data/geo_paraguay_full.json')
@@ -35,6 +37,24 @@ export function BarrioAutocompleteField({
.catch(() => {}) .catch(() => {})
}, []) }, [])
// Close dropdown on scroll so the fixed-position list doesn't drift from the input
useEffect(() => {
if (!open) return
const close = () => setOpen(false)
window.addEventListener('scroll', close, { passive: true, capture: true })
return () => window.removeEventListener('scroll', close, { capture: true })
}, [open])
function computeDropdownStyle() {
if (!inputRef.current) return
const rect = inputRef.current.getBoundingClientRect()
setDropdownStyle({
top: rect.bottom + 4,
left: rect.left,
width: rect.width,
})
}
const barrios: string[] = (() => { const barrios: string[] = (() => {
if (!geoData) return [] if (!geoData) return []
if (departamento && ciudad) { if (departamento && ciudad) {
@@ -54,6 +74,7 @@ export function BarrioAutocompleteField({
function handleInput(v: string) { function handleInput(v: string) {
onChange(v) onChange(v)
computeDropdownStyle()
setOpen(true) setOpen(true)
setActiveIdx(-1) setActiveIdx(-1)
} }
@@ -104,9 +125,10 @@ export function BarrioAutocompleteField({
aria-activedescendant={activeIdx >= 0 ? `${name}-opt-${activeIdx}` : undefined} aria-activedescendant={activeIdx >= 0 ? `${name}-opt-${activeIdx}` : undefined}
autoComplete="off" autoComplete="off"
className="text-short-input" className="text-short-input"
ref={inputRef}
onChange={(e) => handleInput(e.target.value)} onChange={(e) => handleInput(e.target.value)}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
onFocus={() => { if (suggestions.length > 0) setOpen(true) }} onFocus={() => { if (suggestions.length > 0) { computeDropdownStyle(); setOpen(true) } }}
onBlur={() => setTimeout(() => setOpen(false), 150)} onBlur={() => setTimeout(() => setOpen(false), 150)}
/> />
{open && suggestions.length > 0 && ( {open && suggestions.length > 0 && (
@@ -115,6 +137,7 @@ export function BarrioAutocompleteField({
role="listbox" role="listbox"
className="barrio-autocomplete-list" className="barrio-autocomplete-list"
aria-label="Sugerencias de barrios" aria-label="Sugerencias de barrios"
style={dropdownStyle}
> >
{suggestions.map((barrio, i) => ( {suggestions.map((barrio, i) => (
<li <li