1.7 KiB
1.7 KiB
0057 Back goes to its parent, through history only when the parent is behind
Status: Accepted · Area: architecture · Date: 2026-10-09 · Decided by: user · Supersedes: 0038
Context
Adopted from kasra-pay's decisions 0038 and 0039. Under 0038, back called router.back() whenever any page of this site was behind. After a form moves on with router.push (profile save to حساب کاربری, checkout to the channel), that entry is the finished form, and a double press went back two entries.
Decision
- Keep 0038's roots (خانه, جستجو, the dashboards, a creator's own channel, the landing, login),
hreffixed targets,useBackTarget,onBack, andDeskBackon desktop. - Back is a link to
parentHref(home by default). A plain click goes back in history only when the previous entry isparentHref; otherwise it opens it. - A page reached from several places (a post,
/account/install) setsbackToPrevious: it goes back to any previous page of this site. A page withoutparentHrefnames no parent, so it does the same. - Go back with
navigation.traverseTo(key)from next/link'sonNavigate, oruseGoBackfrom code, so repeated presses land on the same entry.
Alternatives
- 0038's any-page rule for every screen: returns to finished forms.
- Exact match for every screen: a post opened from خانه would open its channel instead.
Consequences
- Opened from anywhere but its parent, a back with a named parent pushes the parent instead of restoring the page behind.
- Browsers without the Navigation API always open the parent route.
- Checkout's
router.pushto the channel still leaves checkout behind the channel, whose back goes to any previous page; that is debt.