by aidenn0 · 8y ago · 0 comments
It's not all that hard to build a React or Angular apps that use proper links along with the browser history API. Designed properly, the apps should be able to load their state and render correctly even when deep-linked to somewhere other than the app's top level.
This isn't a new concern - I remember paying attention to this back in the old days of SPAs using GWT back in 2009/2010.
Unfortunately, many web apps choose to ignore this. On the bright side, lots of them get it right, too.
What if state should be destroyed when you press the back button? What if I open an image in a photo app, click a button to delete it, and go to a 'deletion successful' page.
Should clicking the back button return me to a page containing the image? A page containing 'this image has been deleted'? The website I was on before I was on the photo app?
Which actions defines a history-worthy state change? Should clicking around a menu generate 10 history events? What about toggling a checkbox? What about an action that changes most of the information on a page? Should that generate a history event? What if that action is bringing an in-app tab to the forefront?
What if there is an obvious history event that should be generated, but there is no good reason for why a user would want to go back to that state?
It doesn't even matter how you answer all of the above questions - other people will have different answers for them, and have different expectations for how the back button should work, on the same app.
Good luck getting a group of people to agree on what "non-broken" back button behavior is.
Some people don't care about a back button in a single page application and it isn't "trivial" to implement properly. It requires libraries, polyfill support, etc. And in a world where everyone is complaining about js bloat, it should be no surprise why it exists.
I haven't checked in a while, I wonder if this situation improved? A lot of these frameworks market themselves as dead easy, but I always found a gap between the "dead easy start-up" documentation, and the documentation that essentially amounted to "read the source code."
I wouldn't be surprised if most if not all tutorials ignore it as well.
Humble suggestion: design fads.
My own question would be whether this gets taught anywhere. Because if it does, a few someones need to get fired.
My problem is usually the opposite: I constantly stumble upon websites that use ridiculously large fonts like I'm a grandma that tries to read something on an overkillishly-retina display from meters away. However it doesn't usually bother me when I'm browsing from my desktop 'cause I have options to zoom out; however most of mobile layouts feature something like <meta name="viewport" content="..., minimum-scale=1"> (edit: also mentioned in the article albeit in a bit different context), which makes me choose between intensive vertical scrolling in regular mode and constant horizontal scrolling if I "request desktop site". (Yeah, I know, "reader mode"; it's a reasonable hack but I'm not quite satisfied with any of implementations either, and it only works for whatever browser thinks the main body of the page is.)
Is this everyone else's experience? How has web design been taught lately?
Just don't.
PubMed.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3968624/
(There's still a legacy fallback.)
There are two choices: don't recreate the state -> people will call each other stupid over the phone because they see different things for the same link,
-or-
Recreate the state -> more money, more time,
-or-
Just don't have links at all. Which is what people usually choose because is faster and cheaper.
What changed was that before, "to do the right thing", i.e. have real links, was the easiest and the cheapest. Now to do the same, you need real developers. Even in Angular there is/was a discussion of where to put the state of the app in the url? put it in the path part of in the hash part? the difference being that the hash is not sent to server. So for search engines all those links are just one actually... Which is ironic because Angular is made by a search engine.
To track clicks.
How do screen readers handle these script-based links? I don't mind it from a "I have working eyes and arms" perspective, but I imagine it's kind of a pain for assisted vision?
I guess it might just bother me so much because it shows a fundamental misunderstanding of how the web works.
I've no idea what people expect right clicking a delete link to open in a new tab to do?
I expect it to issue the delete, and then dump the response to the delete into a new tab rather than navigating away from the page that hosts the delete link.
There might be ten other delete links on the original page, and I don't want to delete-back-delete-back-delete-back, when I can just open all of them in a new tab, then go through the tabs to look for errors.
When you get sick of faking it you look into why there is no way to get browser to send real DELETEs and PUTs and w3c verbiage says "because application developers don't seem to need it" ... because they fake it ... because they have to fake it ... because browser don't do it ... because devs don't need it ...
I wonder why these limitations. Especially since you can get past this with an:
button.addEventHandler('click', () => {
fetch('/path/to/resource', { method: 'DELETE' })
});
which seems way less accessible then to have the method there right there as an attribute.Really egregious examples even change the location so that I can copy the URL after clicking, new tab, paste, and hit back in the original, but I can't middle click for a new tab.
But in cases where its behaviour is that of a button (even a button which has the appearance of blue text - think iOS) then onclick is a good choice. Especially for contexts where “open in new tab” makes no sense.
I can’t see any valid reason for using a void link - worst of both worlds?
Seen people make mistakes like this before... Even using a POST when it should be a GET can cause funny behavior. Funny, but not dangerous behavior like using GET instead of POST.
Whenever I bring a new web dev aboard this is my first lesson to them, and I say "all sorts of clients are going to crawl your webapp, so make sure your webapp is coded correctly for it." Browsers are coded with this assumption, bots/crawlers, email clients, etc...
Also, junior devs don't use HTTP error codes and it always ends up biting them at some point. A 200 response with a body that says "server error" isn't going to bubble up through your JS properly.
Yes, I agree it sucks. But there are also no great alternatives without JS.
http://blog.moertel.com/posts/2005-10-25-google-web-accelera...
I’d rather style the thing to look the way it should rather than apply unusual functionality to something.
Maybe we should investigate this ancient tech of the old ones.
Use a separate CSS via link tag? Oh no, I heard that was slow. Set expires cache header for 1 day? Oh no, that makes testing hard for me and what if the CSS changes?
Web developers sometimes use the dumbest reasons to avoid doing good things.
I think these meandering rants are a tad silly.
Allow me to one-up with this: https://github.com/medialize/sass.js/
> API for emscripted libsass to run in the browser
And probably accessibility tools for the blind.