Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Try typing a full word into each password box.

Then, try to undo (Cmd/Ctrl-Z, etc).

Backbone's undoes the typing, one letter at a time. React's behaves correctly and undoes the whole word.

Good job, React (I still see "controlled" inputs on the web today falling prey to the former)





Why is overriding native browser behaviour “better”? I don’t get this line of thinking at all. It’s like those js libraries that hijack scrolling behaviour only to make it more clunky and less responsive than native scrolling.

OP's point is that respecting native behavior (React) is better.

Interestingly, this is the case in Chrome, but in Firefox both React and Backbone exhibit the same behaviour.

Who says which behavior is the correct one?

Seems more like personal preference.


The one that acts the same as the rest of the system. React isn't replacing the input element, so you get native behavior by default.

Deleting the whole word is not the correct undo...

Yeah, it's a lot more complicated than that and has to do with a mix of typing speed and other things (like moving the cursor and focusing in/out of the input). But single character is also always wrong because then it doesn't act like a normal input - characters are grouped together and multiple undone at once. You can try it yourself here in the HN reply box.

wait, why is undoing by word better? I like backbone's approach!

https://jsfiddle.net/pn6bzyhk/1/

Native behavior for comparison. React is following it; Backbone is not. The native behavior on macOS, for instance, undoes all three words in one action: https://imgur.com/a/jKl5exU

(Not your fault: most people misremember this...)


Well played. Have been using Mac OS for 20 years and I did not expect this result, if asked.

This is why you should always be wary about re-implementing OS behaviour yourself in your widgets, you will always miss at least one detail, but more probably dozens of them.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: