Skip to content

Commit 20a2940

Browse files
authored
Merge pull request #113 from DioxusLabs/jk/desktop-cursor-jump
fix: cursor jumping in desktop inputs
2 parents 06205e4 + eb13884 commit 20a2940

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

packages/desktop/src/index.js

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
const bool_attrs = [
2-
"allowfullscreen",
3-
"allowpaymentrequest",
4-
"async",
5-
"autofocus",
6-
"autoplay",
7-
"checked",
8-
"controls",
9-
"default",
10-
"defer",
11-
"disabled",
12-
"formnovalidate",
13-
"hidden",
14-
"ismap",
15-
"itemscope",
16-
"loop",
17-
"multiple",
18-
"muted",
19-
"nomodule",
20-
"novalidate",
21-
"open",
22-
"playsinline",
23-
"readonly",
24-
"required",
25-
"reversed",
26-
"selected",
27-
"truespeed",
28-
]
1+
const bool_attrs = {
2+
allowfullscreen: true,
3+
allowpaymentrequest: true,
4+
async: true,
5+
autofocus: true,
6+
autoplay: true,
7+
checked: true,
8+
controls: true,
9+
default: true,
10+
defer: true,
11+
disabled: true,
12+
formnovalidate: true,
13+
hidden: true,
14+
ismap: true,
15+
itemscope: true,
16+
loop: true,
17+
multiple: true,
18+
muted: true,
19+
nomodule: true,
20+
novalidate: true,
21+
open: true,
22+
playsinline: true,
23+
readonly: true,
24+
required: true,
25+
reversed: true,
26+
selected: true,
27+
truespeed: true,
28+
};
2929

3030
function serialize_event(event) {
3131
switch (event.type) {
@@ -321,6 +321,7 @@ class Interpreter {
321321

322322
CreatePlaceholder(edit) {
323323
let el = document.createElement("pre");
324+
el.hidden = true;
324325
this.stack.push(el);
325326
this.nodes[edit.root] = el;
326327
}
@@ -386,7 +387,9 @@ class Interpreter {
386387
} else {
387388
switch (name) {
388389
case "value":
389-
node.value = value;
390+
if (value != node.value) {
391+
node.value = value;
392+
}
390393
break;
391394
case "checked":
392395
node.checked = value === "true";
@@ -399,7 +402,7 @@ class Interpreter {
399402
break;
400403
default:
401404
// https://github.com/facebook/react/blob/8b88ac2592c5f555f315f9440cbb665dd1e7457a/packages/react-dom/src/shared/DOMProperty.js#L352-L364
402-
if (value == "false" && bool_attrs.indexOf(name)) {
405+
if (value == "false" && bool_attrs.hasOwnProperty(name)) {
403406
node.removeAttribute(name);
404407
} else {
405408
node.setAttribute(name, value);

0 commit comments

Comments
 (0)