GNOME Bugzilla – Bug 699249
Note area not focused when an old note is opened
Last modified: 2018-05-04 12:07:21 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.
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?
*when you open a note that already exists
Created attachment 269088 [details] [review] modifying the focus
I will check your patch tonight (Paris time) but I guess it should apply in both cases, which is what we want
Created attachment 269148 [details] [review] Get focus to note view
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
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
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
(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 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 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)
- 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
Created attachment 275277 [details] [review] Focus old notes
I think it's better to set cursor at the end of old notes, not the beginning.
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.
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.
(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.
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.
-- 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.