After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 699249 - Note area not focused when an old note is opened
Note area not focused when an old note is opened
Status: RESOLVED OBSOLETE
Product: bijiben
Classification: Applications
Component: UI
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Bijiben maintainer(s)
Bijiben maintainer(s)
Depends on:
Blocks: 721024
 
 
Reported: 2013-04-29 17:48 UTC by Kat
Modified: 2018-05-04 12:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
modifying the focus (611 bytes, patch)
2014-02-14 01:07 UTC, Bogdan Petcu
rejected Details | Review
Get focus to note view (2.81 KB, patch)
2014-02-14 21:11 UTC, Pierre-Yves Luyten
none Details | Review
get focus when users click new button to create a new note (1.28 KB, patch)
2014-04-20 06:55 UTC, Chunyang Xu
committed Details | Review
Focus old notes (1.40 KB, patch)
2014-04-27 19:46 UTC, Chunyang Xu
needs-work Details | Review

Description Kat 2013-04-29 17:48:53 UTC
When creating a new note using the "New" button, the note area should be focused so that it is possible to start typing immediately. At the moment, noting seems to be focused.
Comment 1 Bogdan Petcu 2014-02-14 00:24:18 UTC
Hello, I'm new in bug fixing. I would like to work on this bug. I noticed that this is also happening when you open a new note. Is the focus wanted in this situation too?
Comment 2 Bogdan Petcu 2014-02-14 00:25:35 UTC
*when you open a note that already exists
Comment 3 Bogdan Petcu 2014-02-14 01:07:41 UTC
Created attachment 269088 [details] [review]
modifying the focus
Comment 4 Pierre-Yves Luyten 2014-02-14 06:10:35 UTC
I will check your patch tonight (Paris time) but I guess it should apply in both cases, which is what we want
Comment 5 Pierre-Yves Luyten 2014-02-14 21:11:31 UTC
Created attachment 269148 [details] [review]
Get focus to note view
Comment 6 Pierre-Yves Luyten 2014-02-14 21:12:32 UTC
Comment on attachment 269088 [details] [review]
modifying the focus


> 
>     bjb_window_base_switch_to (bwb, BJB_WINDOW_BASE_NOTE_VIEW);
>     gtk_widget_show_all (w);
>+    gtk_widget_set_can_focus (w, TRUE);
>+    gtk_widget_grab_focus (w);
>   }
> }
> 


w is the window, not the widget we want to focus
Comment 7 Pierre-Yves Luyten 2014-02-14 21:14:28 UTC
I tried to focus specifically the widget we want. Unfortunately, this still fails, with below warnings. We might have to connect to WebKitWebView to know when it's loaded, then give the focus. At least I hope that's the sole issue =)




** (bijiben:17279): CRITICAL **: WebKitDOMNode* webkit_dom_range_get_start_container(WebKitDOMRange*, GError**): assertion 'WEBKIT_DOM_IS_RANGE(self)' failed

** (bijiben:17279): CRITICAL **: gushort webkit_dom_node_get_node_type(WebKitDOMNode*): assertion 'WEBKIT_DOM_IS_NODE(self)' failed
Comment 8 Chunyang Xu 2014-04-20 06:55:04 UTC
Created attachment 274747 [details] [review]
get focus when users click new button to create a new note

see http://stackoverflow.com/questions/11475398/can-i-use-autofocus-on-an-element-with-contenteditable
Comment 9 Chunyang Xu 2014-04-20 07:02:18 UTC
(In reply to comment #8)
> Created an attachment (id=274747) [details] [review]
> get focus when users click new button to create a new note
> 
> see
> http://stackoverflow.com/questions/11475398/can-i-use-autofocus-on-an-element-with-contenteditable

When open a existing note, the cursor will be located at the beginning of the text not the end, this is a problem.
Comment 10 Pierre-Yves Luyten 2014-04-20 08:24:33 UTC
Comment on attachment 274747 [details] [review]
get focus when users click new button to create a new note

>+           "<body contenteditable='ture' id='editable'>"

=true


I did not test yet but this should work. I might be able to remove some "grab_focus" call on the code, this can be another commit.

Also, the bug needs to remain open since we only fix new notes. Old notes will never be fixed. Using some regexp while saving might be a way. Or better, if we can ask WebKit to add the focus before we save the note, in order to make it work next time.
Comment 11 Pierre-Yves Luyten 2014-04-20 19:09:31 UTC
Comment on attachment 274747 [details] [review]
get focus when users click new button to create a new note

Commit as 16ffc8abf9930fb0e670f65d8e3581e6379ab978

I just amended the "true" typo and the commit msg. (Author is preserved)
Comment 12 Pierre-Yves Luyten 2014-04-20 19:11:46 UTC
- I do confirm it works. Thanks much! this one was really annoying and a lot of users will appreciate
- I wrote above I could remove some code, but it appears I was wrong, the "bjb_note_view_grab_focus" code is still needed.
- Another confirmation : we need to keep this bug opened for old notes ==> amending bug title
Comment 13 Chunyang Xu 2014-04-27 19:46:41 UTC
Created attachment 275277 [details] [review]
Focus old notes
Comment 14 Chunyang Xu 2014-04-27 19:49:09 UTC
I think it's better to set cursor at the end of old notes, not the beginning.
Comment 15 Pierre-Yves Luyten 2014-04-27 21:59:41 UTC
Review of attachment 275277 [details] [review]:

Does not work for me. Maybe 

regex = g_regex_new("<body>(.*)<div>", 0, 0, NULL);

should be

regex = g_regex_new("<body(.*)<div>", 0, 0, NULL);

in case there is already a string. We might check the note manually.
Comment 16 Pierre-Yves Luyten 2014-04-27 21:59:48 UTC
Review of attachment 275277 [details] [review]:

Does not work for me. Maybe 

regex = g_regex_new("<body>(.*)<div>", 0, 0, NULL);

should be

regex = g_regex_new("<body(.*)<div>", 0, 0, NULL);

in case there is already a string. We might check the note manually.
Comment 17 Pierre-Yves Luyten 2014-04-27 22:01:10 UTC
Review of attachment 275277 [details] [review]:

Does not work for me. Maybe 

regex = g_regex_new("<body>(.*)<div>", 0, 0, NULL);

should be

regex = g_regex_new("<body(.*)<div>", 0, 0, NULL);

We might check the note manually to ensure.
Comment 18 Pierre-Yves Luyten 2014-04-27 22:01:10 UTC
Review of attachment 275277 [details] [review]:

Does not work for me. Maybe 

regex = g_regex_new("<body>(.*)<div>", 0, 0, NULL);

should be

regex = g_regex_new("<body(.*)<div>", 0, 0, NULL);

We might check the note manually to ensure.
Comment 19 Chunyang Xu 2014-04-28 04:53:42 UTC
(In reply to comment #18)
> Review of attachment 275277 [details] [review]:
> 
> Does not work for me. Maybe 
> 

If you don't edit the old notes, It will not really change the content of old note file, in ~/.local/share/bijiben. It just adds some code for webkit renderer to focus the notes. But anyway, both new and old notes are focused.

> regex = g_regex_new("<body>(.*)<div>", 0, 0, NULL);
> 
> should be
> 
> regex = g_regex_new("<body(.*)<div>", 0, 0, NULL);
> 
> We might check the note manually to ensure.

old local notes:    ...<body>xxx<div>...
new local notes:   ...<body id=...>xxx<script...><div>...

So I think 
s/<body>(.*)<div>/<body id=...>\1<script...><div>
works fine.
Comment 20 Pierre-Yves Luyten 2014-04-28 17:01:19 UTC
ok, i've did not understand at first becuase in some cases the regex fails and notes has no focus when opened. This is why i did reply this.

before: body:<html xmlns="http://www.w3.org/1999/xhtml"><body>alors voila.</body></html>
after: body:<html xmlns="http://www.w3.org/1999/xhtml"><body>alors voila.</body></html>

But obviously in these cases, without regex this is the same. I think we should work on old notes before pushing this improvement. 

Another right place might be deserializer. Or keep on coding on the editor.
Comment 21 GNOME Infrastructure Team 2018-05-04 12:07:21 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-notes/issues/7.