TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Why do web sites not place the cursor for input?

80 pointsby backendanonalmost 2 years ago
To their credit, Microsoft puts the cursor in the text field ready for me to type in my authenticator code. Most web sites I've found, do not. So I look up with my shiny new code, ready to start typing, realize I need to move my hand to the mouse, place the cursor into the field then there's a 50% change I've forgotten the code and have to look back at my phone.

15 comments

ttfkamalmost 2 years ago
A lot (the majority?) of web developers know their framework and how to script things but don&#x27;t know that HTML has been able to do things like this out of the box for over a decade. Even IE 10 supported it. So much simpler and more reliable than using JavaScript.<p><pre><code> &lt;input name=&quot;foo&quot; type=&quot;text&quot; autofocus&gt; </code></pre> <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;HTML&#x2F;Global_attributes&#x2F;autofocus" rel="nofollow noreferrer">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;HTML&#x2F;Global_att...</a>
评论 #36836725 未加载
评论 #36844575 未加载
评论 #36840840 未加载
评论 #36840915 未加载
mtmailalmost 2 years ago
(From <a href="https:&#x2F;&#x2F;github.com&#x2F;sveltejs&#x2F;svelte&#x2F;issues&#x2F;6629#issuecomment-898497953">https:&#x2F;&#x2F;github.com&#x2F;sveltejs&#x2F;svelte&#x2F;issues&#x2F;6629#issuecomment-...</a>) &quot;The reason why autofocus should be generally avoided, is that it&#x27;s messing up the focus order for screenreaders and similar assistive technologies. Additionally, logical &quot;focus order&quot; is also a success criterion on the official WCAG 2.0 accessibility guidelines by the W3C.&quot; <a href="https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;UNDERSTANDING-WCAG20&#x2F;navigation-mechanisms-focus-order.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;UNDERSTANDING-WCAG20&#x2F;navigation-mechan...</a>
评论 #36836974 未加载
评论 #36837026 未加载
评论 #36836762 未加载
评论 #36836847 未加载
评论 #36837608 未加载
评论 #36837631 未加载
评论 #36837282 未加载
评论 #36847277 未加载
评论 #36837255 未加载
illamintalmost 2 years ago
Cynically, I feel like these details are often lost in the two-week sprint cycle or other realities of modern software development process. The Figma file didn&#x27;t specify autofocus, the PM doesn&#x27;t care about it, and the engineer just wants to close their ticket so they can move on to the next one. It&#x27;s a login page, who cares? What revenue or business metric does it drive? Same reason the input field for the code doesn&#x27;t have its input mode set to numeric (to show a numeric keyboard on mobile devices), and the same reason the email field doesn&#x27;t have the email input mode set (to show the email input keyboard with @ and . prominently featured).
评论 #36837435 未加载
评论 #36837289 未加载
评论 #36842013 未加载
alexchamberlainalmost 2 years ago
I can get over that, but I&#x27;ve used a couple of websites where hitting enter in the code box doesn&#x27;t submit the code and log you in - that is unforgivable.
评论 #36836709 未加载
评论 #36836708 未加载
评论 #36837382 未加载
bdcravensalmost 2 years ago
Principle of Least Astonishment<p>&quot;In user interface design and software design,[1] the principle of least astonishment (POLA), also known as principle of least surprise,[a] proposes that a component of a system should behave in a way that most users will expect it to behave, and therefore not astonish or surprise users.&quot;<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Principle_of_least_astonishment" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Principle_of_least_astonishmen...</a><p>Such a feature would negatively affect accessibility, without some sort of accessible clue about where the cursor was moved.
评论 #36836391 未加载
评论 #36836341 未加载
评论 #36836716 未加载
评论 #36836682 未加载
bdavbdavalmost 2 years ago
Similar vein, there’s a special place In hell for web &#x2F; iOS developers who don’t flag input fields correctly to allow autofill &#x2F; password managers to work. I see it in a lot of crappy legacy iOS apps.
评论 #36842711 未加载
ravenstinealmost 2 years ago
Even worse is when the input is initially has the cursor, but then the site&#x27;s absolute genius SSR rehydration kicks in, not only erasing what you just typed, but also removing focus from the input.
eimrinealmost 2 years ago
I needed 22 tab presses to achieve the comment field here w&#x2F;o mouse and tab enter to send.
al_be_backalmost 2 years ago
a couple of reason not to focus:<p>1. on mobile devices, a focused &lt;input&gt; also triggers Keyboard to open, that in turn may cause the page&#x2F;content to scroll suddenly etc. that could annoy the user, 2. if there&#x27;s content to read (a message, Terms etc), the user may end up not fill the form at all
评论 #36837621 未加载
dimaoralmost 2 years ago
Sendgrid&#x27;s lack of autofocus in the 2FA page is particularly annoying
codingclawsalmost 2 years ago
One reason I don&#x27;t see mentioned: you can&#x27;t use keyboard shortcuts that use the backspace key.
评论 #36842730 未加载
评论 #36838411 未加载
NoZebra120vClipalmost 2 years ago
While I normally feel like the designers don&#x27;t care about accessibility, I feel like in this case, it may be a bit of a security issue. The site wants to do all they can to foil automation, for example, and if the caret isn&#x27;t helpfully placed exactly where they need to start input, a human can figure that out better than a bot.
评论 #36836423 未加载
mdwaltersalmost 2 years ago
its because they&#x27;re using autofocus
htfualmost 2 years ago
Vimium.<p>gi
retrocryptidalmost 2 years ago
The web is not designed to be useful for any purpose. It is designed to demonstrate plausible &quot;technologies&quot; developed by companies whose investors want to sell them to other companies.<p>Anything beyond basic WEB 1.0 is intended to be &quot;plausible&quot; instead of &quot;useful.&quot;
评论 #36836812 未加载