Navigation in digitransit-ui should, whenever possible, adhere to the Material Design guidelines. Read that document first to get an idea of the concept and terminology.
Changing itinerary search inputs invalidates pending requests from the previous search. Late results and errors must not update the view or trigger further query iterations. This also applies to alternative plans and earlier/later requests, and pending results are ignored when the itinerary page unmounts.
Unmounting the itinerary page always stops its MQTT client, including subscriptions started by the navigator, regardless of whether itinerary vehicles are displayed.
The URL path is the only source of the page language; there is no language cookie and no
Accept-Language negotiation.
- The default language (
config.defaultLanguage) is served without a prefix:/reitti/A/B. - Other languages in
config.availableLanguageskeep a/{lang}/prefix on every page:/en/reitti/A/B. /{defaultLanguage}/…gets a 301 to the same path without the prefix (/fi/x→/x). WithredirectReittiopasParams, old reittiopas prefixes that aren't available (e.g./ru/) get a 302.- Paths with repeated slashes or backslashes get a 301 to single slashes (
//sv/x→/sv/x,src/server/middleware/slashMiddleware.js) before anything else runs.
src/server/middleware/languageMiddleware.js reads the prefix with getLanguageFromPath
(src/shared/utils/languageUtils.js) and sets res.locals.language, which shell.js renders as
<html lang>. The shell also adds hreflang links for every available language, an x-default
link (the default language) and a self-referencing canonical link. These have no query: our
parameters only change the time, view or tracking of a page, not which page it is.
Automatic SSO login starts on the same pages in every language (isSsoLoginPage in
src/server/passport-openid-connect/openidConnect.js). The page a user logs in or out from decides
the language of the identity provider and of the page shown after logout.
src/client/client.jsx reads the language from document.documentElement.lang and gives the
router a basename of getLanguagePrefix(config, language) (farce's basename middleware, see
createHistoryMiddlewares in src/client/routes/routes.jsx). So routes, links and router.push() use
paths without the prefix, and the router adds it to the browser URL.
Which location to use:
- App logic (route matching, analytics context, which page this is):
match.location, without the prefix. - A real browser URL (login/logout
returnTo, manifeststart_url,og:url, page view analytics):router.createHref(match.location), with the prefix. window.location: only outside the router, e.g. before it starts inclient.jsx. ESLint flags reads ofwindow.location/document.locationpathname,searchandhrefin client code; disable the rule on a line only with a reason.
The language links (LangSelect) use createLanguageHref, which swaps the prefix of the current
page. They are plain links, so switching language loads the page again with a new basename.
The embedded search (/haku) is an exception: its language comes from a ?lang= query parameter,
since existing embeds on other sites use it.
The Up button is only present in the mobile layout of the service. The Up button moves the user to the view above it in the hierarchy. It does not move across the crosslinks in the service. The Up button is replaced by the home button in the desktop UI, as there is only a single level of views.
The browser's back button should move the user back to the previous view in the browser history. The back button also closes any menus and modals, such as the main menu and search settings, search modals, opened tabs on the front page. It should also minimize any maximized maps on mobile. The back button should not return you to the previous state of the same view, such as when moving between tabs in the route view, when updating settings in the summary view or viewing different itineraries on the desktop version.

