Hi,

as reported on IRC, there seems to be an issue with form elements
losing focus while being edited with an external editor. This causes
the input field to remain disabled when returning to the website. The
attached patch should solve this issue. Testing / comments appreciated!

Hannes
diff --git a/main.c b/main.c
index d70f88a..493a701 100644
--- a/main.c
+++ b/main.c
@@ -1894,6 +1894,9 @@ open_editor(const Arg *arg) {
         g_free(message);
         return FALSE;
     }
+    jsapi_evaluate_script("editElem = document.activeElement", &value, &message);
+    g_free(value);
+    g_free(message);
 
     /* write text into temporary file */
     temp_file_handle = mkstemp(temp_file_name);
@@ -1933,10 +1936,10 @@ open_editor(const Arg *arg) {
    
     /* mark the active text box as "under processing" */
     jsapi_evaluate_script(
-        "document.activeElement.disabled = true;"
-        "document.activeElement.originalBackground = "
-        "   document.activeElement.style.background;"
-        "document.activeElement.style.background = '#aaaaaa';"
+        "editElem.disabled = true;"
+        "editElem.originalBackground = "
+        "   editElem.style.background;"
+        "editElem.style.background = '#aaaaaa';"
         ,&value, &message);
 
     g_child_watch_add(child_pid, _resume_from_editor, temp_file_name);
@@ -1959,7 +1962,7 @@ void
 _resume_from_editor(GPid child_pid, int child_status, gpointer data) {
     FILE *fp;
     GString *set_value_js = g_string_new(
-        "document.activeElement.value = \"");
+        "editElem.value = \"");
     g_spawn_close_pid(child_pid);
     gchar *value = NULL, *message = NULL;
     gchar *temp_file_name = data;
@@ -1968,8 +1971,8 @@ _resume_from_editor(GPid child_pid, int child_status, gpointer data) {
     int char_read;
 
     jsapi_evaluate_script(
-        "document.activeElement.disabled = true;"
-        "document.activeElement.style.background = '#aaaaaa';"
+        "editElem.disabled = true;"
+        "editElem.style.background = '#aaaaaa';"
         ,&value, &message);
     g_free(value);
     g_free(message);
@@ -1991,7 +1994,7 @@ _resume_from_editor(GPid child_pid, int child_status, gpointer data) {
         /* this would be too weird to even emit an error message */
         goto error_exit;
     }
-    jsapi_evaluate_script("document.activeElement.value = '';", 
+    jsapi_evaluate_script("editElem.value = '';", 
         &value, &message);
     g_free(value);
     g_free(message);
@@ -2026,9 +2029,9 @@ _resume_from_editor(GPid child_pid, int child_status, gpointer data) {
     /* Fall through, error and normal exit are identical */
 error_exit:
     jsapi_evaluate_script(
-        "document.activeElement.disabled = false;"
-        "document.activeElement.style.background ="
-        "   document.activeElement.originalBackground;"
+        "editElem.disabled = false;"
+        "editElem.style.background ="
+        "   editElem.originalBackground;"
         ,&value, &message);
 
     g_string_free(set_value_js, TRUE);
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Vimprobable-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vimprobable-users

Reply via email to