From ad330623e32a8f760495a3d6a7ace2dd1a39b2e8 Mon Sep 17 00:00:00 2001 From: Benjamin Dupont <4503241+Benjozork@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:33:49 -0500 Subject: [PATCH] fix: clearing fix info fields --- .../MFD/pages/FMS/F-PLN/MfdFmsFplnFixInfo.tsx | 47 ++++++++++--------- .../src/MFD/pages/common/DataEntryFormats.tsx | 4 ++ 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFplnFixInfo.tsx b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFplnFixInfo.tsx index 3d5ddc82d7f..9019a20a9ae 100644 --- a/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFplnFixInfo.tsx +++ b/fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFplnFixInfo.tsx @@ -67,8 +67,9 @@ export class MfdFmsFplnFixInfo extends FmsPage { readonlyValue={this.flightPlan.fixInfos[value].map((it) => it?.fix ?? null)} onModified={async (text) => { - if (!text) { - return null; + if (text === null) { + void this.props.fmcService.master!.flightPlanService.setFixInfoEntry(value, null); + return; } const fix = await WaypointEntryUtils.getOrCreateWaypoint(this.props.fmcService.master!, text, true); @@ -113,19 +114,19 @@ export class MfdFmsFplnFixInfo extends FmsPage { (it) => it?.radials?.[0]?.magneticBearing ?? null, )} onModified={(radial) => { - if (radial === null) { - return; - } - this.props.fmcService.master?.flightPlanService.editFixInfoEntry(value, (fixInfo) => { if (!fixInfo.radials) { fixInfo.radials = []; } - fixInfo.radials[0] = { - magneticBearing: radial, - trueBearing: A32NX_Util.magneticToTrue(radial, A32NX_Util.getRadialMagVar(fixInfo.fix)), - }; + if (radial !== null) { + fixInfo.radials[0] = { + magneticBearing: radial, + trueBearing: A32NX_Util.magneticToTrue(radial, A32NX_Util.getRadialMagVar(fixInfo.fix)), + }; + } else { + delete fixInfo.radials[0]; + } return fixInfo; }); @@ -147,19 +148,19 @@ export class MfdFmsFplnFixInfo extends FmsPage { (it) => it?.radials?.[1]?.magneticBearing ?? null, )} onModified={(radial) => { - if (radial === null) { - return; - } - this.props.fmcService.master?.flightPlanService.editFixInfoEntry(value, (fixInfo) => { if (!fixInfo.radials) { fixInfo.radials = []; } - fixInfo.radials[1] = { - magneticBearing: radial, - trueBearing: A32NX_Util.magneticToTrue(radial, A32NX_Util.getRadialMagVar(fixInfo.fix)), - }; + if (radial !== null) { + fixInfo.radials[1] = { + magneticBearing: radial, + trueBearing: A32NX_Util.magneticToTrue(radial, A32NX_Util.getRadialMagVar(fixInfo.fix)), + }; + } else { + delete fixInfo.radials[1]; + } return fixInfo; }); @@ -186,16 +187,16 @@ export class MfdFmsFplnFixInfo extends FmsPage { disabled={this.flightPlan.fixInfos[value].map((it) => it?.fix === undefined)} readonlyValue={this.flightPlan.fixInfos[value].map((it) => it?.radii?.[0]?.radius ?? null)} onModified={(radius) => { - if (radius === null) { - return; - } - this.props.fmcService.master?.flightPlanService.editFixInfoEntry(value, (fixInfo) => { if (!fixInfo.radii) { fixInfo.radii = []; } - fixInfo.radii[0] = { radius }; + if (radius !== null) { + fixInfo.radii[0] = { radius }; + } else { + delete fixInfo.radii[0]; + } return fixInfo; }); diff --git a/fbw-a380x/src/systems/instruments/src/MFD/pages/common/DataEntryFormats.tsx b/fbw-a380x/src/systems/instruments/src/MFD/pages/common/DataEntryFormats.tsx index 67bd90475f4..5b498f5fe50 100644 --- a/fbw-a380x/src/systems/instruments/src/MFD/pages/common/DataEntryFormats.tsx +++ b/fbw-a380x/src/systems/instruments/src/MFD/pages/common/DataEntryFormats.tsx @@ -786,6 +786,10 @@ export class FixFormat implements DataEntryFormat { public readonly maxDigits = 7; async parse(input: string): Promise { + if (input.trim().length === 0) { + return null; + } + if (WaypointEntryUtils.isPlaceFormat(input) || WaypointEntryUtils.isRunwayFormat(input)) { return input; }