Kundenansicht neu P1: Fahrstuhl-Zeile, Desktop-Menü und Tastaturzustand

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-16 16:14:55 +00:00
1 parent 4953c8fd0f
commit 710c57cf87
3 files changed
+301 -2

No files matched your search

+105 -2
View File
@@ -3,7 +3,7 @@
/* ---------- Blatt (Etage 2) ---------- */
.kn-blatt { max-width: 1160px; padding: 36px 48px 80px; background: var(--kn-bg); }
.kn-blatt { background: var(--kn-bg); }
.kn-haupt[inert] { display: none; } /* Desktop: die Unterseite ersetzt die Hauptseite in der Spalte */
.kn-brot { margin-bottom: 8px; font-size: 13px; line-height: 20px; color: var(--kn-text-2); }
@@ -21,7 +21,7 @@
@media (max-width: 880px), (pointer: coarse) and (max-height: 500px) {
.kn { --kn-unten: calc(var(--kn-zeile-h) + env(safe-area-inset-bottom)); }
.kn-blatt {
position: fixed; inset: 0 0 var(--kn-unten, var(--kn-zeile-h)); z-index: 20; max-width: none; padding: 0 16px 24px;
position: fixed; inset: calc(var(--kn-kopf-h) + env(safe-area-inset-top)) 0 var(--kn-unten, var(--kn-zeile-h)); z-index: 20;
overflow-y: auto; overscroll-behavior: contain; border-radius: 12px 12px 0 0;
box-shadow: 0 0 0 1px rgba(26,31,54,.06), 0 -8px 24px rgba(26,31,54,.1);
transform: translateY(100%); transition: transform 550ms var(--kn-bremse);
@@ -74,3 +74,106 @@
.kn-konto-zeile { min-height: 46px; }
}
@keyframes kn-sheet-hoch { from { transform: translateY(100%); } }
/* ---------- Gerüst: Spalte, Inhalt, Menü (Desktop) und Kopf ---------- */
.kn { --kn-kopf-h: 52px; }
.kn-skip { position: absolute; top: -48px; left: 8px; z-index: 100; padding: 8px 12px; border-radius: var(--kn-radius); background: var(--kn-accent); color: #fff; font-weight: 600; }
.kn-skip:focus { top: 8px; }
.kn-nur-leser { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.kn-banner { position: relative; z-index: 30; display: flex; align-items: center; justify-content: center; gap: 12px; height: 36px; padding: 0 16px; background: var(--kn-accent); color: #fff; font-size: 13px; line-height: 20px; }
.kn-banner > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kn-banner button { flex: none; min-height: 28px; padding: 0 4px; color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.kn-banner:not([hidden]) ~ .kn-huelle .kn-menue { top: 36px; }
.kn-menue { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; gap: 2px; width: var(--kn-sidebar-w); padding: 20px 12px; overflow-y: auto; border-right: 1px solid var(--kn-line); background: var(--kn-bg); }
.kn-marke { padding: 0 10px 16px; font-size: 15px; line-height: 24px; font-weight: 600; }
.kn-nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 6px 10px; border-radius: var(--kn-radius); font-size: 14px; line-height: 20px; font-weight: 500; color: var(--kn-text-2); text-align: left; }
.kn-nav-item:hover { background: var(--kn-bg-hover); color: var(--kn-text); }
.kn-nav-item[aria-current="page"] { background: var(--kn-accent-soft); color: var(--kn-accent); font-weight: 600; }
.kn-nav-zahl { font-size: 12px; line-height: 16px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--kn-text-3); }
.kn-nav-zahl--heiss { color: var(--kn-rot-fg); font-weight: 600; }
.kn-spalte { position: relative; min-height: 100vh; margin-left: var(--kn-sidebar-w); }
.kn-kopf { position: absolute; top: 0; right: 0; z-index: 10; display: flex; align-items: center; height: var(--kn-kopf-h); padding: 0 24px; }
.kn-kopf-titel { display: none; }
.kn-haupt, .kn-blatt { max-width: 1160px; padding: 36px 48px 80px; }
.kn-haupt .kn-titel, .kn-blatt .kn-titel { margin: 0 0 24px; }
#kn-fehler { margin: 16px 48px 0; }
@media (max-width: 1100px) {
.kn-haupt, .kn-blatt { padding: 32px 28px 80px; }
#kn-fehler { margin: 16px 28px 0; }
.kn-streifen { padding: 0 28px; }
}
@media (max-width: 880px), (pointer: coarse) and (max-height: 500px) {
.kn-menue { display: none; }
.kn-spalte { margin-left: 0; }
.kn-kopf { position: sticky; right: auto; justify-content: space-between; height: auto; min-height: calc(var(--kn-kopf-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 20px; border-bottom: 1px solid transparent; background: var(--kn-bg); transition: border-color 300ms; }
.kn-scrolled .kn-kopf { border-bottom-color: var(--kn-line); }
.kn-kopf-titel { display: block; font-size: 15px; line-height: 22px; font-weight: 600; opacity: 0; transform: translateY(5px); transition: opacity 250ms, transform 250ms; }
.kn-titled .kn-kopf-titel { opacity: 1; transform: none; }
.kn-haupt { max-width: none; padding: 2px 16px calc(var(--kn-zeile-h) + env(safe-area-inset-bottom) + 28px); }
.kn-blatt { max-width: none; padding: 0 16px 24px; }
.kn-haupt .kn-titel, .kn-blatt .kn-titel { margin: 6px 0 10px; font-size: 28px; line-height: 34px; }
.kn-banner button { min-height: 44px; }
#kn-fehler { margin: 12px 16px 0; }
}
/* ---------- Leiste (Handy): Fahrstuhl-Zeile mit Balken ---------- */
.kn-leiste { display: none; }
.kn-leiste-reel { height: var(--kn-zeile-h); overflow: hidden; }
.kn-rw { display: flex; align-items: center; height: var(--kn-zeile-h); padding: 0 4px; transition: transform 550ms var(--kn-bremse), visibility 0s; }
.kn-leiste-reel[data-etage="offen"] .kn-rw { transform: translateY(-56px); }
.kn-leiste-reel[data-etage="offen"] #kn-zeile-haupt, .kn-leiste-reel:not([data-etage="offen"]) #kn-zeile-etage { visibility: hidden; transition: transform 550ms var(--kn-bremse), visibility 0s 550ms; }
.kn-balken { position: relative; flex: 1; min-width: 0; height: 44px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.kn-balken::-webkit-scrollbar { display: none; }
.kn-balken-basis { position: relative; z-index: 1; display: flex; width: max-content; min-width: 100%; height: 44px; }
.kn-gleiter { position: absolute; z-index: 2; top: 4px; left: 0; height: 36px; overflow: hidden; border-radius: 6px; background: var(--kn-accent); pointer-events: none; transition: transform 550ms var(--kn-feder), width 550ms var(--kn-feder); }
.kn-overlay { position: absolute; top: -4px; left: 0; display: flex; height: 44px; transition: transform 550ms var(--kn-feder); }
.kn-fb .kn-overlay { display: none; }
.kn-fb .kn-gleiter { z-index: 0; }
.kn-fb .kn-t[aria-selected="true"] { color: #fff; }
.kn-t { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 4px; font-size: 15px; font-weight: 600; color: var(--kn-text-2); white-space: nowrap; text-align: center; transition: color 250ms; }
.kn-t:focus-visible { outline-offset: -2px; border-radius: 6px; }
.kn-schrift-klein .kn-t { font-size: 14px; }
.kn-overlay .kn-t { color: #fff; }
.kn-l { position: relative; line-height: 20px; }
.kn-zahl { position: absolute; top: -9px; left: 100%; min-width: 16px; height: 16px; margin-left: -6px; padding: 0 4px; border-radius: 8px; background: #b3093c; color: #fff; font-size: 11px; line-height: 16px; font-weight: 700; text-align: center; box-shadow: 0 0 0 2px var(--kn-bg); animation: kn-zahl-ein 400ms cubic-bezier(.3,1.5,.5,1); }
.kn-overlay .kn-zahl { box-shadow: 0 0 0 2px var(--kn-accent); }
.kn-reiter-t .kn-zahl { top: -7px; }
.kn-zahl--weg { transform: scale(0); transition: transform 250ms; animation: none; }
@keyframes kn-zahl-ein { from { transform: scale(0); } }
@media (max-width: 880px), (pointer: coarse) and (max-height: 500px) {
.kn-leiste { display: block; position: fixed; right: 0; bottom: 0; left: 0; z-index: 40; border-top: 1px solid var(--kn-line); background: var(--kn-bg); padding-bottom: env(safe-area-inset-bottom); }
.kn.kn-tastatur { --kn-unten: 0px; }
}
.kn-tastatur .kn-leiste { transform: translateY(110%); visibility: hidden; transition: transform 400ms var(--kn-bremse), visibility 0s 400ms; }
/* ---------- Querformat (Handy gedreht): niedrigere Zeile, keine große Überschrift ---------- */
@media (max-height: 500px) and (max-width: 880px), (max-height: 500px) and (pointer: coarse) {
.kn { --kn-zeile-h: 44px; --kn-kopf-h: 44px; }
.kn-leiste-reel[data-etage="offen"] .kn-rw { transform: translateY(-44px); }
.kn-haupt .kn-titel, .kn-blatt .kn-titel { display: none; }
.kn-kopf-titel { opacity: 1; transform: none; }
}
/* ---------- Bewegung reduziert: keine Federn, höchstens kurzes Überblenden ---------- */
@media (prefers-reduced-motion: reduce) {
.kn-gleiter, .kn-overlay, .kn-rw, .kn-t { transition: none; }
.kn-blatt { transform: none; opacity: 0; transition: opacity 150ms; }
.kn-blatt--auf { opacity: 1; }
.kn-konto-scrim, .kn-konto { animation: kn-einblenden 150ms ease-out; }
.kn-zahl { animation: none; }
.kn-zahl--weg { transition: none; }
.kn-kopf, .kn-kopf-titel, .kn-tastatur .kn-leiste { transition-duration: 150ms; }
}
+114
View File
@@ -0,0 +1,114 @@
/* Kundenansicht neu: Navigation der Hülle. Handy: Fahrstuhl-Zeile unten mit vier Wörtern und schwarzem Balken (reiter.js, art 'balken').
Desktop: Menü links, Wörter ohne Icons. Beide zeigen dieselben Zähler. Dazu der reine Zustand der Bildschirmtastatur
(Leiste und Streifen verschwinden nur bei Texteingabe) und seine Verdrahtung mit visualViewport, focusin und focusout. */
import { h, leeren } from './dom.js'
import { baueReiter, anzeigeText } from './reiter.js'
// Genau einmal in JS; das CSS führt dieselbe Abfrage (basis.css, huelle.css).
export const HANDY_ABFRAGE = '(max-width: 880px), (pointer: coarse) and (max-height: 500px)'
export const WOERTER = [
{ key: 'website', label: 'Website' },
{ key: 'funktionen', label: 'Funktionen' },
{ key: 'chat', label: 'Chat', einheit: 'ungelesen' },
{ key: 'vertraege', label: 'Verträge', einheit: 'offen', ausrufText: 'Zahlung fehlgeschlagen' },
]
const beschriftung = (wort, anzeige) => {
const text = anzeigeText(anzeige)
if (!text) return null
if (anzeige.ausruf) return `${wort.label}, ${wort.ausrufText ?? 'Hinweis'}`
return `${wort.label}, ${text}${wort.einheit ? ` ${wort.einheit}` : ''}`
}
/** Fahrstuhl-Zeile in `haupt` und Menü in `menue` bauen. onWahl(bereich) wird bei Klick auf ein Wort gerufen. */
export function baueNavigation({ haupt, menue, onWahl }) {
const reiter = baueReiter({ eintraege: WOERTER, aktiv: '', art: 'balken', ariaLabel: 'Bereiche', bei: (key) => onWahl(key) })
leeren(haupt).append(reiter)
const knoepfe = Object.fromEntries(WOERTER.map((w) => [w.key, h('button', { class: 'kn-nav-item', type: 'button', 'data-bereich': w.key, on: { click: () => onWahl(w.key) } }, h('span', { class: 'kn-nav-text' }, w.label))]))
leeren(menue).append(h('span', { class: 'kn-marke' }, 'WEBklar'), ...WOERTER.map((w) => knoepfe[w.key]))
function setzeAktiv(bereich) {
reiter.setzeAktiv(bereich)
for (const w of WOERTER) {
if (w.key === bereich) knoepfe[w.key].setAttribute('aria-current', 'page')
else knoepfe[w.key].removeAttribute('aria-current')
}
}
function zeigeZahl(wort, anzeige) {
reiter.setzeAnzeige(wort.key, anzeige)
const knopf = knoepfe[wort.key]
let zahl = knopf.querySelector('.kn-nav-zahl')
const text = anzeigeText(anzeige)
if (!text) { zahl?.remove(); knopf.removeAttribute('aria-label'); return }
if (!zahl) { zahl = h('span', { class: 'kn-nav-zahl' }); knopf.append(zahl) }
zahl.textContent = text
zahl.classList.toggle('kn-nav-zahl--heiss', wort.key === 'chat' || anzeige.ausruf === true)
knopf.setAttribute('aria-label', beschriftung(wort, anzeige))
}
function setzeZaehler({ chat = 0, vertraege = { zahl: 0, ausruf: false } } = {}) {
zeigeZahl(WOERTER[2], { zahl: chat, ausruf: false })
zeigeZahl(WOERTER[3], { zahl: vertraege.zahl ?? 0, ausruf: vertraege.ausruf === true })
}
/** Etage 2 offen: das Reel (Elternelement der Hauptzeile) fährt eine Zeile hoch, die Hauptzeile ist gesperrt. */
function setzeEtage(offen) {
const reel = haupt.parentElement
if (offen) { reel?.setAttribute('data-etage', 'offen'); haupt.setAttribute('inert', '') }
else { reel?.removeAttribute('data-etage'); haupt.removeAttribute('inert') }
}
return { setzeAktiv, setzeZaehler, setzeEtage }
}
const SCHWELLE = 150 // so viel kleiner als die volle Höhe heißt: Tastatur offen (wie app.js:2475)
const TEXT_FELD = 'textarea, input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=date]):not([type=button]):not([type=submit]):not([type=range]):not([type=color])'
/** Reiner Zustand { voll, breite, offen, tippt }. Ereignisse: { art:'vv', hoehe, breite, textfeldAktiv?, grob? }, { art:'fokus', textfeld, grob }, { art:'unfokus', textfeldAktiv }. */
export function tastaturZustand(alt, ereignis) {
if (ereignis.art === 'fokus') return { ...alt, tippt: Boolean(ereignis.textfeld && ereignis.grob) }
if (ereignis.art === 'unfokus') return { ...alt, tippt: alt.tippt && Boolean(ereignis.textfeldAktiv) }
// visualViewport: ein Breitenwechsel (Drehen, Zoom) setzt die volle Höhe zurück, sonst wächst sie mit
const gedreht = Math.abs(ereignis.breite - alt.breite) > 1
const voll = gedreht ? ereignis.hoehe : Math.max(alt.voll, ereignis.hoehe)
const offen = gedreht ? false : ereignis.hoehe < voll - SCHWELLE
let tippt = alt.tippt
if (alt.offen && !offen) tippt = false // Tastatur ging zu, auch per Android-Geste ohne Blur
else if (offen && ereignis.textfeldAktiv && ereignis.grob) tippt = true
return { voll, breite: gedreht ? ereignis.breite : alt.breite, offen, tippt }
}
/** Leiste und Streifen sind nur bei Texteingabe weg. */
export const leisteSichtbar = (zustand) => !zustand.tippt
/** Verdrahtung mit visualViewport, focusin und focusout; onChange(zustand) nur bei Änderung von offen oder tippt. */
export function beobachteTastatur({ win = window, doc = document, onChange }) {
const vv = win.visualViewport
const grob = () => Boolean(win.matchMedia?.('(pointer: coarse)').matches)
const istTextfeld = (el) => Boolean(el?.matches?.(TEXT_FELD))
let z = { voll: vv?.height ?? win.innerHeight, breite: vv?.width ?? win.innerWidth, offen: false, tippt: false }
const wende = (ereignis) => {
const alt = z
z = tastaturZustand(alt, ereignis)
if (z.offen !== alt.offen || z.tippt !== alt.tippt) onChange(z)
}
const beiFokus = (ev) => wende({ art: 'fokus', textfeld: istTextfeld(ev.target), grob: grob() })
// Nach dem Blur kurz warten: wechselt der Fokus von Feld zu Feld, bleibt die Tastatur
const beiUnfokus = () => win.setTimeout(() => wende({ art: 'unfokus', textfeldAktiv: istTextfeld(doc.activeElement) }), 80)
const beiVv = () => wende({ art: 'vv', hoehe: vv.height, breite: vv.width, textfeldAktiv: istTextfeld(doc.activeElement), grob: grob() })
doc.addEventListener('focusin', beiFokus)
doc.addEventListener('focusout', beiUnfokus)
vv?.addEventListener('resize', beiVv)
return {
stand: () => z,
beende() {
doc.removeEventListener('focusin', beiFokus)
doc.removeEventListener('focusout', beiUnfokus)
vv?.removeEventListener('resize', beiVv)
},
}
}
+82
View File
@@ -0,0 +1,82 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { installFakeDom } from './support/fakeDom.js'
import { h } from '../public/neu/dom.js'
import { HANDY_ABFRAGE, baueNavigation, tastaturZustand, leisteSichtbar, beobachteTastatur } from '../public/neu/leiste.js'
import { lies, handyTeil, HANDY } from './support/knHuelle.js'
test('Leiste: vier Wörter, Auswahl, Zähler mit Beschriftung, "!" und 99+, Etage sperrt die Hauptzeile', async () => {
const fx = installFakeDom()
try {
const haupt = h('div'); const reel = h('div', null, haupt); const menue = h('nav'); const gew = []
const n = baueNavigation({ haupt, menue, onWahl: (k) => gew.push(k) }); const tabs = fx.alle(haupt, '[role=tab]')
assert.deepEqual(tabs.map((t) => t.textContent), ['Website', 'Funktionen', 'Chat', 'Verträge'])
n.setzeAktiv('chat'); assert.deepEqual(tabs.map((t) => t.getAttribute('aria-selected')), ['false', 'false', 'true', 'false']); assert.equal(fx.finde(menue, '[aria-current=page]').textContent, 'Chat')
await fx.klick(tabs[3]); assert.deepEqual(gew, ['vertraege'])
n.setzeZaehler({ chat: 2, vertraege: { zahl: 1, ausruf: false } })
assert.deepEqual([tabs[2].getAttribute('aria-label'), tabs[3].getAttribute('aria-label'), fx.finde(menue, '.kn-nav-zahl').textContent], ['Chat, 2 ungelesen', 'Verträge, 1 offen', '2'])
n.setzeZaehler({ chat: 150, vertraege: { zahl: 5, ausruf: true } })
assert.deepEqual([fx.finde(tabs[2], '.kn-zahl').textContent, fx.finde(tabs[3], '.kn-zahl').textContent, tabs[3].getAttribute('aria-label')], ['99+', '!', 'Verträge, Zahlung fehlgeschlagen'])
n.setzeZaehler({ chat: 0, vertraege: { zahl: 0, ausruf: false } }); assert.equal(fx.finde(menue, '.kn-nav-zahl'), null)
assert.deepEqual(fx.alle(menue, 'button').map((b) => b.textContent), ['Website', 'Funktionen', 'Chat', 'Verträge'])
n.setzeEtage(true); assert.deepEqual([reel.getAttribute('data-etage'), haupt.hasAttribute('inert')], ['offen', true])
n.setzeEtage(false); assert.equal(haupt.hasAttribute('inert'), false)
} finally { fx.restore() }
})
test('tastaturZustand: öffnen unter voll-150, Android-Geste ohne Blur, Drehen, nur Textfelder am Touch (Review Focus 4)', () => {
let z = { voll: 844, breite: 390, offen: false, tippt: false }
z = tastaturZustand(z, { art: 'vv', hoehe: 560, breite: 390, textfeldAktiv: true, grob: true }); assert.deepEqual([z.offen, z.tippt, leisteSichtbar(z)], [true, true, false])
z = tastaturZustand(z, { art: 'vv', hoehe: 700, breite: 390 }); assert.deepEqual([z.offen, z.tippt, leisteSichtbar(z)], [false, false, true]) // 700 >= 694, ohne Blur
z = tastaturZustand(z, { art: 'vv', hoehe: 390, breite: 844 }); assert.deepEqual([z.voll, z.breite, z.offen], [390, 844, false])
assert.deepEqual([true, false].map((grob) => tastaturZustand(z, { art: 'fokus', textfeld: true, grob }).tippt), [true, false])
assert.equal(tastaturZustand({ ...z, tippt: true }, { art: 'unfokus', textfeldAktiv: false }).tippt, false)
})
test('huelle.css: Desktop ist Grundregel, Handy überschreibt (Abfrage wörtlich, 44 px, Safe-Area, Reel, Gleiter, Menü, Bewegung)', () => {
assert.equal(`@media ${HANDY_ABFRAGE}`, HANDY)
const css = lies('huelle.css'); const handy = handyTeil(css)
assert.match(css, /\.kn-t\s*\{(?=[^}]*min-height:\s*44px)(?=[^}]*font-size:\s*15px)(?=[^}]*font-weight:\s*600)/s)
assert.match(css, /\.kn-schrift-klein \.kn-t\s*\{[^}]*font-size:\s*14px/s)
assert.match(css, /\.kn-menue\s*\{(?=[^}]*width:\s*var\(--kn-sidebar-w\))(?=[^}]*border-right:\s*1px solid var\(--kn-line\))/s)
assert.match(handy, /\.kn-menue\s*\{[^}]*display:\s*none/s); assert.match(handy, /\.kn-leiste\s*\{[^}]*padding-bottom:\s*env\(safe-area-inset-bottom\)/s)
assert.match(css, /\[data-etage="offen"\][^{]*\{[^}]*translateY\(-56px\)/s)
assert.match(css, /\.kn-gleiter\s*\{(?=[^}]*top:\s*4px)(?=[^}]*height:\s*36px)(?=[^}]*border-radius:\s*6px)(?=[^}]*background:\s*var\(--kn-accent\))/s)
assert.match(css, /\.kn-tastatur \.kn-leiste[^{]*\{[^}]*(translateY\(110%\)|display:\s*none)/s)
assert.match(css, /@media \(prefers-reduced-motion: reduce\)[\s\S]*150ms/)
})
test('Menü und Leiste: Klick im Menü wählt, Aktiv und Zähler laufen in beiden Navigationen, unbekannter Bereich wählt nichts', async () => {
const fx = installFakeDom()
try {
const haupt = h('div'); const menue = h('nav'); const gew = []
const n = baueNavigation({ haupt, menue, onWahl: (k) => gew.push(k) })
const knoepfe = fx.alle(menue, 'button')
await fx.klick(knoepfe[1]); assert.deepEqual(gew, ['funktionen'])
assert.match(fx.text(menue), /WEBklar/); assert.equal(fx.alle(menue, 'svg, img').length, 0) // Marke als Text, keine Icons
n.setzeAktiv('vertraege'); assert.deepEqual(knoepfe.map((b) => b.hasAttribute('aria-current')), [false, false, false, true])
n.setzeAktiv('gibtesnicht'); assert.deepEqual([fx.alle(menue, '[aria-current=page]').length, fx.alle(haupt, '[aria-selected=true]').length], [0, 0])
n.setzeZaehler({ chat: 3, vertraege: { zahl: 0, ausruf: true } })
assert.deepEqual([knoepfe[2].getAttribute('aria-label'), fx.finde(knoepfe[2], '.kn-nav-zahl').textContent, knoepfe[3].getAttribute('aria-label'), fx.finde(knoepfe[3], '.kn-nav-zahl').textContent], ['Chat, 3 ungelesen', '3', 'Verträge, Zahlung fehlgeschlagen', '!'])
n.setzeZaehler({ chat: 0, vertraege: { zahl: 2, ausruf: false } })
assert.deepEqual([knoepfe[2].hasAttribute('aria-label'), knoepfe[3].getAttribute('aria-label')], [false, 'Verträge, 2 offen'])
n.setzeZaehler({}); assert.equal(fx.finde(menue, '.kn-nav-zahl'), null) // ohne Angaben alles auf null
} finally { fx.restore() }
})
test('beobachteTastatur: Fokus, Tastatur auf und zu ohne Blur, Blur mit Verzögerung, Aufräumen', () => {
const sender = (felder = {}) => { const hoerer = {}; return Object.assign({ addEventListener(typ, fn) { (hoerer[typ] ??= []).push(fn) }, removeEventListener(typ, fn) { hoerer[typ] = (hoerer[typ] ?? []).filter((x) => x !== fn) }, senden(typ, ev = {}) { for (const fn of hoerer[typ] ?? []) fn({ type: typ, ...ev }) } }, felder) }
const vv = sender({ height: 800, width: 400 }); const doc = sender({ activeElement: null })
const spaeter = []; const meldungen = []; const feld = { matches: () => true }
const win = { visualViewport: vv, innerHeight: 800, innerWidth: 400, matchMedia: () => ({ matches: true }), setTimeout: (fn) => spaeter.push(fn) }
const t = beobachteTastatur({ win, doc, onChange: (z) => meldungen.push([z.offen, z.tippt]) })
doc.activeElement = feld; doc.senden('focusin', { target: feld })
vv.height = 480; vv.senden('resize')
assert.deepEqual([meldungen, t.stand().offen, leisteSichtbar(t.stand())], [[[false, true], [true, true]], true, false])
vv.height = 800; vv.senden('resize') // Android-Geste: Tastatur zu, das Feld behält den Fokus
assert.deepEqual([meldungen.at(-1), leisteSichtbar(t.stand())], [[false, false], true])
doc.senden('focusin', { target: feld }); assert.deepEqual(meldungen.at(-1), [false, true]) // erneut ins Feld tippen: Leiste weg
doc.activeElement = null; doc.senden('focusout'); assert.equal(spaeter.length, 1); spaeter.shift()()
assert.deepEqual(meldungen.at(-1), [false, false])
t.beende(); const n = meldungen.length; doc.senden('focusin', { target: feld }); vv.height = 400; vv.senden('resize'); assert.equal(meldungen.length, n)
})