Files
Maurice bb515ac3cc fix(planner): booking codes stay blurred in the edit forms too
With "Blur booking codes" on, the bookings list and the transport details
hid a code, but opening the same booking to edit it printed the code in
the clear: the reservation and transport forms with every per-segment
code of a flight or train, the hotel editor in the day panel and the
three phone sheets. The stay's own code in the day panel, the booking
strip in the place inspector and the booking lines under a stay and a
stop on the phone showed it plainly as well.

One shared BookingCodeInput and BlurredCode now carry the setting to all
of them. A filled code field stays blurred until it is hovered or
focused, so clicking, tapping or tabbing into it still reveals the code
for editing, and the value is saved exactly as typed. With the setting
off nothing changes, and the PDF export and the share pages stay as
they were.
2026-09-22 21:48:22 +02:00

25 lines
1.2 KiB
TypeScript

/**
* Whether a booking code is hidden by the "Blur booking codes" setting
* (blur_booking_codes) at the moment of the call.
*
* The surfaces hide a code in one of two ways: the older desktop ones set an
* inline `filter: blur(...)`, the rest carry a Tailwind `blur-[...]` class. The
* blur may sit on the element holding the code or on the box right around it,
* so the element and its two nearest ancestors are checked. A focus variant
* (`focus:blur-none`) counts as lifted while the element has focus, because
* that is what the browser would render.
*/
export function isBlurred(el: Element | null): boolean {
let node: Element | null = el
for (let depth = 0; node && depth < 3; depth++, node = node.parentElement) {
const h = node as HTMLElement
if (h.style?.filter?.includes('blur(')) return true
const tokens = (typeof h.className === 'string' ? h.className : '').split(/\s+/)
const blurClass = tokens.some(tk => /^blur(-.+)?$/.test(tk) && tk !== 'blur-none')
const liftedByFocus = h === document.activeElement
&& tokens.some(tk => /^focus(-visible|-within)?:(blur-none|filter-none)$/.test(tk))
if (blurClass && !liftedByFocus) return true
}
return false
}