3 ms·
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 correc
by lelandfe 1y ago
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)
- croes 1y agoWho says which behavior is the correct one? Seems more like personal preference.
- Izkata 1y agoThe 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.
- deleted 1y ago[deleted]
- saxenaabhi 1y agowait, why is undoing by word better? I like backbone's approach!
- lelandfe 1y agohttps://jsfiddle.net/pn6bzyhk/1/ 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 https://imgur.com/a/jKl5exU (Not your fault: most people misremember this...)
- warpspin 1y agoWell 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.
- BoredPositron 1y agoDeleting the whole word is not the correct undo...
- Izkata 1y agoYeah, 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.
- VladVladikoff 1y agoWhy 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.
- deleted 1y ago[deleted]
- deleted 1y ago[deleted]
- kaoD 1y agoOP's point is that respecting native behavior (React) is better.
- smokel 1y agoInterestingly, this is the case in Chrome, but in Firefox both React and Backbone exhibit the same behaviour.