Kallithea issues archive

Issue #250: Parent and Child navigation links at changeset doesn't work always

Reported by: Jani Tiainen
State: resolved
Created on: 2016-10-20 11:28
Updated on: 2018-05-18 20:15

Description

Child and Parent navigation links at changeset doesn't work always.

For example at https://kallithea-scm.org/repos/kallithea/changeset/38d1c99cd0005c1df5a37692615356c918dbe068 neither "parent" or "child" link doesn't go anywhere.

Attachments

Comments

Comment by Mads Kiilerich, on 2016-10-20 16:17

It seems to work fine for me.

Comment by Jani Tiainen, on 2016-10-20 16:23

Doesn't work for me. Both links points to same changeset tested using Chrome and FireFox, Microsoft IE 11 and Edge.

This is generated links from DOM:

<div class="parents">
  <div id="parent_link" class="changeset_hash">
    <i style="color:#036185" class="icon-left-open"></i>
    <a href="#">Parent rev.</a>
  </div>
</div>

<div class="children">
  <div id="child_link" class="changeset_hash">
    <a href="#">Child rev.</a>
    <i style="color:#036185" class="icon-right-open"></i>
  </div>
</div>

Comment by domruf, on 2016-10-20 17:01

I have no idea why but the link it self only points to #. It appears that the behavior is handled via javascript, so if you tell your browser to open the 'link' in a new tab, it in fact opens the same page again instead of the changeset before or after this one. This indeed seems wrong to me and should be fixed.

Comment by Jani Tiainen, on 2016-10-20 17:25

Ok, this lead me to do further investigation and it seems that Javascript $.onready() crashes in following code:

    <script type="text/javascript">
      $(document).ready(function(){
          $('.code-difftable').on('click', '.add-bubble', function(e){
              show_comment_form($(this));
          });

          move_comments($(".comments .comments-list-chunk"));

          pyroutes.register('changeset_home',
                            "/repos/%25%28repo_name%29s/changeset/%25%28revision%29s",
                            ['repo_name', 'revision']);

at line move_comments($(".comments .comments-list-chunk"));

So actual parent/child onclick events never get registered.

Complete error message:

base.js?ver=0.3.99:1258 Uncaught TypeError: Cannot set property 'chunks' of null
    at MentionsAutoComplete (https://kallithea-scm.org/repos/js/base.js?ver=0.3.99:1258:34)
    at _comment_div_append_form (https://kallithea-scm.org/repos/js/base.js?ver=0.3.99:752:5)
    at HTMLDivElement.<anonymous> (https://kallithea-scm.org/repos/js/base.js?ver=0.3.99:622:17)
    at Function.each (https://kallithea-scm.org/repos/js/jquery.min.js?ver=0.3.99:2:2881)
    at n.fn.init.each (https://kallithea-scm.org/repos/js/jquery.min.js?ver=0.3.99:2:846)
    at move_comments (https://kallithea-scm.org/repos/js/base.js?ver=0.3.99:611:21)
    at HTMLDocument.<anonymous> (https://kallithea-scm.org/repos/kallithea/changeset/4e9f5ef98dc492676edc9642f5ba23162919c868:885:11)
    at i (https://kallithea-scm.org/repos/js/jquery.min.js?ver=0.3.99:2:27449)
    at Object.fireWith [as resolveWith] (https://kallithea-scm.org/repos/js/jquery.min.js?ver=0.3.99:2:28213)
    at Function.ready (https://kallithea-scm.org/repos/js/jquery.min.js?ver=0.3.99:2:30006)

Comment by domruf, on 2016-10-21 08:22

Okay it happens if you are not logged in and therefore there is no comment textarea element.

base.js then tries to activate autocomplete for an non existing element which leads to this error.

Here is my quickfix

diff -r 6a4b277322f6 kallithea/public/js/base.js
--- a/kallithea/public/js/base.js   Thu Oct 20 18:25:43 2016 +0200
+++ b/kallithea/public/js/base.js   Fri Oct 21 10:19:10 2016 +0200
@@ -702,7 +702,9 @@
     });

     tooltip_activate();
-    MentionsAutoComplete($textarea, $mentions_container, _USERS_AC_DATA);
+    if($textarea.length > 0) {
+      MentionsAutoComplete($textarea, $mentions_container, _USERS_AC_DATA);
+    }
     if (f_path) {
         $textarea.focus();
     }

Comment by Mads Kiilerich, on 2016-10-21 13:11

Nice catch!

Comment by Thomas De Schampheleire, on 2018-05-18 20:15

Fixed with 2c8c1a604154.