3 ms·
The Back button on Mastodon takes you back to your previous page in your history stack interestingly.
by ecuaflo 3y ago
The Back button on Mastodon takes you back to your previous page in your history stack interestingly.
- fastball 3y agoSeems like there shouldn't even be a back button there if I have nowhere to go back to on Mastodon.
- fwlr 3y agoWeb pages have the ability to fire a “back event” that (I am pretty sure) works identically to clicking the back button on your browser. I imagine they’re using this because it’s very simple, you just put onClick(History.back) on the button and you’ve implemented a fully functional back button. https://developer.mozilla.org/en-US/docs/Web/API/History/back https://developer.mozilla.org/en-US/docs/Web/API/History/bac... Many sites will of course eschew this simple solution in favour of custom back button logic (usually to the mild detriment of the user experience).
- robinson7d 3y agoOn the other hand: why? Browsers already have a back button that works that way. Users are used to back buttons on the page moving up some in-app hierarchy, which, admittedly maybe they oughtn’t be used to because maybe it’s not a good pattern in the first place. But instead of reimplementing the browser’s one and potentially confusing the users, why not remove the button entirely and have people use their browser’s more consistent UI? If the extra space is awkward surely there’s something else that can go there. There are useful cases for history.back, but I’m not sure a back button is it.
- fwlr 3y agoThere are good uses for app-specific back buttons, for sure! Two cases I’ve seen - one is a site with “single page app”ish flow for reading sequential posts, where rather than reloading the entire site it fetches just the JSON data for next and previous posts and updates the HTML; the back button here uses the already-fetched data rather than getting the whole site again. The other case used custom back logic on their site’s back button on form pages to avoid “re-sending form” pop-ups and to avoid losing entered form data. When I said “mildly detrimental” I was thinking of a specific example (go back to the previous page that is on the same domain, implemented solely to improve metrics), so perhaps I shouldn’t have said “usually”.
- ecuaflo 3y agoFound the offending logic here [1]. Looks like it uses React Router's history.goBack method [2], which probably defaults to the browser history method you mentioned when there's nothing else. That if statement should be conditioned on the react router history, not window.history. I submitted a PR to fix this [3] [1] https://github.com/mastodon/mastodon/blob/ff3b7069cf9dd8fc3fa479184db833fbd46472a4/app/javascript/mastodon/components/column_back_button.jsx#L25 https://github.com/mastodon/mastodon/blob/ff3b7069cf9dd8fc3f... [2] https://v5.reactrouter.com/web/api/history https://v5.reactrouter.com/web/api/history [3] https://github.com/mastodon/mastodon/pull/24835 https://github.com/mastodon/mastodon/pull/24835
- wodenokoto 3y agoI thought this was a joke on how many sites high-jack the browser back button, joking that "my back button takes me back!" is a novel thing on the modern web. But there is a link on the page that says "back", which acts just clicking the browser back button. I think this has been an available feature to web developers for well over a decade.
- rjh29 3y ago> I think this has been an available feature to web developers for well over a decade. window.history.back() is as old as JavaScript I think. It was supported in Firefox 1 which was released in 2002.