From 1d2819e18e88fcad6331f4f5730e867afc28410c Mon Sep 17 00:00:00 2001
From: LookedPath <2457111+LookedPath@users.noreply.github.com>
Date: Sun, 25 Oct 2026 18:16:01 +0000
Subject: [PATCH] Dismiss the mobile NOC sheet when opening link details
---
CHANGELOG.md | 2 ++
site/index.html | 7 ++++---
tests/issues.test.js | 45 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 695c841..f0ad822 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
+- Opening a link from the NOC on mobile now closes the NOC sheet so the link details are visible.
+
## [1.27.0] — 2026-10-25
- New "Leased lines" tab in the NOC dashboard shows which leased waves, fabric circuits and dark fiber IRUs between your POPs you could replace with cheaper capacity: leased dark fiber, your own fiber or your own subsea cable. Each option lists the up-front cost, the monthly cost, how much you would save and when it pays for itself, with a button to plan the build.
diff --git a/site/index.html b/site/index.html
index 5e09015..eba081c 100644
--- a/site/index.html
+++ b/site/index.html
@@ -2566,7 +2566,7 @@ const ACT={
if(UI.confirm!==id){UI.confirm=id;renderBank();return;}UI.confirm=null;if(!spend(cost)){renderBank();return;}S.loans=S.loans.filter(x=>x!==l);track('loan_repaid');
toast(B.equity?tr('You bought out {bank}.
They flew off to find another startup.',{bank:esc(B.name)}):tr('Loan from {bank} repaid early.',{bank:esc(B.name)}),'good');after();renderBank();},
leaseSwap:({a,b,src})=>{if(!S.pops[a]||!S.pops[b]||a===b)return;$('dash').hidden=true;UI.lmode='df';UI.dfSrc=['lease','build','cable'].includes(src)?src:isSub(a,b)?'cable':'build';UI.dfSys=lvl()>=3?'roadm':'lite';openLinkModal(a,b);},
- dashLink:({id})=>{$('dash').hidden=true;UI.confirm=null;UI.sel={type:'link',id};renderPanel();},
+ dashLink:({id})=>{$('dash').hidden=true;selectLink(id);},
animSet:({v})=>{if(!['auto','on','off'].includes(v))return;UI.anim=v;try{localStorage.setItem('sot-anim',v);}catch(e){}applyAnim();refreshSettings();},
soundSet:({v})=>{UI.muted=v==='off';try{localStorage.setItem('sot-mute',UI.muted?'1':'0');}catch(e){}renderHUD();refreshSettings();},
langSet:({v})=>{if(!Object.hasOwn(LANGS,v)||v===LANG)return;try{localStorage.setItem('sot-lang',v);}catch(e){}save();location.reload();},
@@ -2583,7 +2583,7 @@ const ACT={
openModal(pitchHtml(false));},
pitchSkip:()=>{const p=UI.pendGame;UI.pendGame=null;UI.pitched=true;if(p)beginGame(...p);else closeModal();},
focusCity:({city})=>{selectCity(city);const C=CITY[city];cam.x=C.x;cam.y=C.y;cam.z=Math.max(cam.z,1.2);if(innerWidth<760)UI.leftOpen=false;renderLeft();},
- selLink:({id})=>{UI.sel={type:'link',id};UI.confirm=null;renderPanel();},
+ selLink:({id})=>selectLink(id),
buildPop:({city})=>{if(S.pops[city])return;if(cnCity(city)&&!cnOk()){toast(tr('You need a license first.
Foreign networks need a joint venture to build in mainland China.'),'bad');sfx('err');return;}if(!spend(popCost(city)))return;S.pops[city]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};floater(CITY[city].x,CITY[city].y-30,tr('New POP!'),'#FF4F9A');UI.tab='cust';after();},
launchBB:({city})=>{const p=S.pops[city];if(!p||p.bb)return;const C=CITY[city];if(!spend(bbCost(city)))return;p.bb={d:Math.max(8,C.P*0.03)};floater(C.x,C.y-30,tr('Eyeballs online!'),'#16A866');after();},
ad:({city})=>{const p=S.pops[city];if(!p||!p.bb)return;if(!spend(8000))return;p.boost=S.day+30;floater(CITY[city].x,CITY[city].y-30,tr('Ad campaign!'),'#FF8A3D');after();},
@@ -2808,6 +2808,7 @@ function chWhy(l,o){const O=OPT[o];if(O.lvl>lvl())return tr('Unlocks at customer
function bbCost(c){return 15000+CITY[c].P*20;}
function after(){if(S)purgeInc();compute();checkGoals();renderAll();if(S&&!$('dash').hidden)renderDash();save();}
const isTablet=()=>innerWidth>760&&innerWidth<=1200;
+function selectLink(id){UI.sel={type:'link',id};UI.confirm=null;if(isTablet()||isPhone())UI.leftOpen=false;$('panel').classList.remove('full');renderPanel();renderLeft();}
function selectCity(c){UI.sel={type:'city',id:c};UI.confirm=null;if(isTablet()||isPhone())UI.leftOpen=false;const P=$('panel');if(P)P.classList.remove('full');if(!S.pops[c])UI.tab='cust';renderPanel();}
/* ================= SAVE ================= */
@@ -3991,7 +3992,7 @@ function endPtr(e){
if(d.mode==='link'){if(UI.snap&&UI.snap.id!==d.from){openLinkModal(d.from,UI.snap.id);sfx('click');}}
else if(!d.moved&&S){const h=hitCity(e.clientX,e.clientY);
if(h){selectCity(h.id);renderLeft();sfx('click');}
- else{const l=hitLink(e.clientX,e.clientY);if(l){UI.sel={type:'link',id:l};UI.confirm=null;if(isTablet())UI.leftOpen=false;renderPanel();renderLeft();sfx('click');}else{UI.sel=null;renderPanel();renderLeft();}}}
+ else{const l=hitLink(e.clientX,e.clientY);if(l){selectLink(l);sfx('click');}else{UI.sel=null;renderPanel();renderLeft();}}}
UI.drag=null;UI.snap=null;cv.classList.remove('linking');cv.style.cursor='grab';renderHint();
}
// A cancelled pointer (scroll takeover, palm rejection, system gesture) is not a tap or a drop.
diff --git a/tests/issues.test.js b/tests/issues.test.js
index 5a03bb9..c33267d 100644
--- a/tests/issues.test.js
+++ b/tests/issues.test.js
@@ -859,3 +859,48 @@ test('save migration checks diversity using the imported cable unlock', () => {
assert.deepEqual(errors, []);
dom.window.close();
});
+
+test('NOC link navigation replaces the phone and tablet sheet immediately', () => {
+ for (const [width, height, coarse] of [[390, 844, false], [1024, 768, false], [1300, 450, true]]) {
+ const { ev, dom, errors } = load();
+ base(ev);
+ ev(`innerWidth=${width};innerHeight=${height};window.matchMedia=()=>({matches:${coarse}})`);
+ ev("S.links.push({id:'noc-link',a:'fra',b:'ams',kind:'wave',tier:0,km:400,mo:100,cut:0});R.load['noc-link']=capOf(S.links.find(l=>l.id==='noc-link'))*0.95");
+ for (const action of ['dashLink', 'selLink']) {
+ ev("UI.sel=null;UI.left='noc';UI.leftOpen=true;renderPanel();renderLeft();$('left').classList.add('full');$('panel').classList.add('full');UI.confirm='stale'");
+ assert.equal(ev("$('left').classList.contains('closed')"), false);
+ if (action === 'dashLink') ev("UI.dtab='infra';ACT.dash()");
+ // Use the actual dashboard or congested-link button, rather than invoking its handler.
+ const root = action === 'dashLink' ? '#dashCard' : '#leftBody';
+ ev(`document.querySelector('${root} [data-act=${action}][data-args*=noc-link]').click()`);
+ assert.equal(ev("$('dash').hidden"), true);
+ assert.equal(ev('UI.leftOpen'), false, `${action} dismisses NOC at ${width}px`);
+ assert.equal(ev("$('left').classList.contains('closed')"), true, 'DOM closes before a game tick');
+ assert.equal(ev("$('panel').hidden"), false);
+ assert.equal(ev('UI.sel.id'), 'noc-link');
+ assert.equal(ev('UI.sel.type'), 'link');
+ assert.equal(ev('UI.confirm'), null);
+ assert.equal(ev("$('panel').classList.contains('full')"), false, 'new selection starts at normal height');
+ }
+ ev("ACT.closePanel();UI.leftOpen=true;UI.left='noc';renderLeft();ACT.connOpen();ACT.goConn({city:'fra',k:'t'})");
+ assert.equal(ev("$('dash').hidden"), true);
+ assert.equal(ev("$('left').classList.contains('closed')"), true, 'connection navigation still dismisses NOC');
+ assert.equal(ev('UI.sel.id'), 'fra');
+ assert.equal(ev('UI.tab'), 'up');
+ assert.deepEqual(errors, []);
+ dom.window.close();
+ }
+});
+
+test('opening a link on desktop keeps the NOC sidebar available', () => {
+ const { ev, dom, errors } = load();
+ base(ev);
+ ev("innerWidth=1440;innerHeight=900;S.links.push({id:'noc-link',a:'fra',b:'ams',kind:'wave',tier:0,km:400,mo:100,cut:0});UI.left='noc';UI.leftOpen=true;renderLeft();ACT.dash();ACT.dashLink({id:'noc-link'})");
+ assert.equal(ev("$('dash').hidden"), true);
+ assert.equal(ev('UI.leftOpen'), true);
+ assert.equal(ev("$('left').classList.contains('closed')"), false);
+ assert.equal(ev("$('panel').hidden"), false);
+ assert.equal(ev('UI.sel.id'), 'noc-link');
+ assert.deepEqual(errors, []);
+ dom.window.close();
+});