Fossil SCM

Chat: disable pasting of text when then input field does NOT have focus and fix complete overwriting of input field when pasting and it DOES have focus. Whether or not we should paste to that field when it does not have focus is debatable and possibly violates the Principle of Least Surprise.

stephan 2020-12-23 22:16 trunk
Commit 87ff8fe35796cc0a9ac8114a3ce3ed1ee268a4249d9056803a6109fd65354226
1 file changed +12 -2
+12 -2
--- src/chat.js
+++ src/chat.js
@@ -64,12 +64,22 @@
6464
if(!item || !item.type) return;
6565
//console.debug("pasted item =",item);
6666
if('file'===item.kind){
6767
updateDropZoneContent(false/*clear prev state*/);
6868
updateDropZoneContent(items[0].getAsFile());
69
- }else if('string'===item.kind){
70
- item.getAsString((v)=>form.msg.value = v);
69
+ }else if(false && 'string'===item.kind){
70
+ /* ----^^^^^ disabled for now:
71
+
72
+ The intent here is that if form.msg is not active, populate
73
+ it with this text, but whether populating it from ctrl-v when
74
+ it does not have focus is a feature or a bug is debatable.
75
+ */
76
+ if(document.activeElement !== form.msg){
77
+ /* Overwrite input field if it DOES NOT have focus,
78
+ otherwise let it do its own paste handling. */
79
+ item.getAsString((v)=>form.msg.value = v);
80
+ }
7181
}
7282
};
7383
if(true){/* Add help button for drag/drop/paste zone */
7484
const help = D.div();
7585
form.file.parentNode.insertBefore(help, form.file);
7686
--- src/chat.js
+++ src/chat.js
@@ -64,12 +64,22 @@
64 if(!item || !item.type) return;
65 //console.debug("pasted item =",item);
66 if('file'===item.kind){
67 updateDropZoneContent(false/*clear prev state*/);
68 updateDropZoneContent(items[0].getAsFile());
69 }else if('string'===item.kind){
70 item.getAsString((v)=>form.msg.value = v);
 
 
 
 
 
 
 
 
 
 
71 }
72 };
73 if(true){/* Add help button for drag/drop/paste zone */
74 const help = D.div();
75 form.file.parentNode.insertBefore(help, form.file);
76
--- src/chat.js
+++ src/chat.js
@@ -64,12 +64,22 @@
64 if(!item || !item.type) return;
65 //console.debug("pasted item =",item);
66 if('file'===item.kind){
67 updateDropZoneContent(false/*clear prev state*/);
68 updateDropZoneContent(items[0].getAsFile());
69 }else if(false && 'string'===item.kind){
70 /* ----^^^^^ disabled for now:
71
72 The intent here is that if form.msg is not active, populate
73 it with this text, but whether populating it from ctrl-v when
74 it does not have focus is a feature or a bug is debatable.
75 */
76 if(document.activeElement !== form.msg){
77 /* Overwrite input field if it DOES NOT have focus,
78 otherwise let it do its own paste handling. */
79 item.getAsString((v)=>form.msg.value = v);
80 }
81 }
82 };
83 if(true){/* Add help button for drag/drop/paste zone */
84 const help = D.div();
85 form.file.parentNode.insertBefore(help, form.file);
86

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button