mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-04 03:19:34 +00:00
fix(frontend): Outbound submit crash on non-mux protocols + tab a11y (B21)
Two issues surfaced on Outbound save: 1. Crash: `Cannot read properties of undefined (reading 'enabled')` at formValuesToWirePayload. The modal hides the Mux switch entirely for non-stream protocols (dns/freedom/blackhole/loopback) and for stream protocols when isMuxAllowed gates it out (xhttp, vless+flow). With the field never registered, validateFields() returns no `mux` key — `values.mux.enabled` then dereferences undefined. Fix: optional chain `values.mux?.enabled` so missing mux skips the mux clause silently. Documented why mux can be absent. 2. Chrome a11y warning: "Blocked aria-hidden on an element because its descendant retained focus" — when the user has an input focused inside one Tab panel and switches to another tab, AntD marks the outgoing panel aria-hidden while focus is still inside. The browser warns, but the focused control is now invisible to AT users. Fix: blur the active element before setActiveKey in onTabChange.
This commit is contained in:
@@ -620,7 +620,10 @@ export function formValuesToWirePayload(values: OutboundFormValues): WireOutboun
|
||||
}
|
||||
|
||||
if (values.sendThrough) result.sendThrough = values.sendThrough;
|
||||
if (values.mux.enabled && muxAllowed(values)) {
|
||||
// mux may be absent when the modal didn't render the Mux switch (non-
|
||||
// stream protocols or when isMuxAllowed gated it out). validateFields()
|
||||
// only returns registered fields, so values.mux can be undefined.
|
||||
if (values.mux?.enabled && muxAllowed(values)) {
|
||||
result.mux = values.mux;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -372,6 +372,13 @@ export default function OutboundFormModal({
|
||||
if (key === '1' && activeKey === '2') {
|
||||
if (!applyJsonToForm()) return;
|
||||
}
|
||||
// Blur the currently focused element before AntD marks the outgoing
|
||||
// tab panel aria-hidden. Without this, a focused input inside the
|
||||
// hidden panel triggers a Chrome a11y warning ("Blocked aria-hidden
|
||||
// on an element because its descendant retained focus").
|
||||
if (typeof document !== 'undefined') {
|
||||
(document.activeElement as HTMLElement | null)?.blur?.();
|
||||
}
|
||||
setActiveKey(key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user