Fossil Forum

schelte 1 week, 3 days ago

Post: Ticket view "newest first" option quirks.

I think the "Show newest first" option on the ticket view page was introduced in response to a question from me, but I cannot find that discussion now. In any case, it has finally been deployed on the tcl repository and I notice some quirks with it: When a user activates the option and then goes to view another ticket, the option is checked but the comments are not displayed newest first.

I suspect the option is checked by the autocomplete functionality of the browser. There doesn't appear to be a cookie related to this functionality. It would be nice if the comments could be ordered according to the state of the checkbutton when the page is loaded. If that is complicated, the checkbutton should at least have an "autocomplete='off'" argument.

If it is indeed the browser's autocomplete that remembers the state of the checkbutton, then it might be useful to have a cookie. That way people who want the newest comments to be listed first don't have to repeat their choice every time the browser forgets the state. I haven't tested it, but I presume that happens whenever the browser is restarted.

The first feedback from a user about the option is that it is easy to miss because it shows up inside the first user comment. They wonder if it would be possible to show it above or alongside the "User comments:" label (outside the shaded area)?

I had a quick look, but found no easy way to customize the checkbutton. I will make an attempt to fix the mentioned quirks myself using custom javascript on the skin. But at the moment I seem to have managed to complete lose the checkbutton on my local checkout. I have no idea how that happened. A fossil configuration pull all --overwrite doesn't bring it back. I'm afraid I will need to investigate that first.

stephan 1 week, 3 days ago

... was introduced in response to a question from me

Introduced by me, so i'll be your support guide today :).

When a user activates the option and then goes to view another ticket, the option is checked but the comments are not displayed newest first.

i coincidentally only recently noticed that but figured that nobody's complained (and i don't use the ticket system more than a few times a year), so left it until someone did ;).

I suspect the option is checked by the autocomplete functionality of the browser.

This has been a recurrent problem - a case of browsers trying to be helpful and instead getting in the way :/.

There doesn't appear to be a cookie related to this functionality.

It's actually stored in your localStorage or (if that's not available) sessionStorage.

i've just checked in a change which appears to solve this for me, in that it seems to keep the checkbox and the view consistent. Please let us know if that's not doing the trick.

but found no easy way to customize the checkbutton.

That one is generated by JavaScript so that it only appears on clients with JS. It's embedded into the fossil binary and the original is in fossil's repo under src/fossil.page.ticket.js. For completeness's sake, and because i just happen to have it open because of the aforementioned checkin, here's 99% of that feature (the rest is a CSS class):

/*
 * This script adds a checkbox to reverse the sorting on any body.tkt
 * pages which contain a .tktCommentArea element.
 */
window.addEventListener( 'load', function() {
  const tgt = document.querySelectorAll('.tktCommentArea');
  if( !tgt ) return;
  const F = globalThis.fossil, D = F.dom;
  let i = 0;
  for(const e of tgt) {
    ++i;
    const childs = e.querySelectorAll('.tktCommentEntry');
    if( !childs || 1===childs.length ) continue;
    const cbReverseKey = 'tktCommentArea:reverse';
    const cbReverse = D.checkbox();
    const cbId = cbReverseKey+':'+i;
    cbReverse.setAttribute('id',cbId);
    const widget = D.append(
      D.div(),
      cbReverse,
      D.label(cbReverse, " Show newest first? ")
    );
    widget.classList.add('newest-first-controls');
    e.parentElement.insertBefore(widget,e);
    const cbReverseIt = ()=>{
      e.classList[cbReverse.checked ? 'add' : 'remove']('reverse');
      F.storage.set(cbReverseKey, cbReverse.checked ? 1 : 0);
    };
    cbReverse.addEventListener('change', cbReverseIt, true);
    cbReverse.checked = !!(+F.storage.get(cbReverseKey, 0));
    cbReverseIt()/*update in case of a forced check by a browser reload*/;
  };
}); // window.addEventListener( 'load' ...
stephan 1 week, 3 days ago

... was introduced in response to a question from me

Introduced by me, so i'll be your support guide today :).

When a user activates the option and then goes to view another ticket, the option is checked but the comments are not displayed newest first.

i coincidentally only recently noticed that but figured that nobody's complained (and i don't use the ticket system more than a few times a year), so left it until someone did ;).

I suspect the option is checked by the autocomplete functionality of the browser.

This has been a recurrent problem - a case of browsers trying to be helpful and instead getting in the way :/.

There doesn't appear to be a cookie related to this functionality.

It's actually stored in your localStorage or (if that's not available) sessionStorage.

i've just checked in a change (edit: fix link) which appears to solve this for me, in that it seems to keep the checkbox and the view consistent. Please let us know if that's not doing the trick.

but found no easy way to customize the checkbutton.

That one is generated by JavaScript so that it only appears on clients with JS. It's embedded into the fossil binary and the original is in fossil's repo under src/fossil.page.ticket.js. For completeness's sake, and because i just happen to have it open because of the aforementioned checkin, here's 99% of that feature (the rest is a CSS class):

/*
 * This script adds a checkbox to reverse the sorting on any body.tkt
 * pages which contain a .tktCommentArea element.
 */
window.addEventListener( 'load', function() {
  const tgt = document.querySelectorAll('.tktCommentArea');
  if( !tgt ) return;
  const F = globalThis.fossil, D = F.dom;
  let i = 0;
  for(const e of tgt) {
    ++i;
    const childs = e.querySelectorAll('.tktCommentEntry');
    if( !childs || 1===childs.length ) continue;
    const cbReverseKey = 'tktCommentArea:reverse';
    const cbReverse = D.checkbox();
    const cbId = cbReverseKey+':'+i;
    cbReverse.setAttribute('id',cbId);
    const widget = D.append(
      D.div(),
      cbReverse,
      D.label(cbReverse, " Show newest first? ")
    );
    widget.classList.add('newest-first-controls');
    e.parentElement.insertBefore(widget,e);
    const cbReverseIt = ()=>{
      e.classList[cbReverse.checked ? 'add' : 'remove']('reverse');
      F.storage.set(cbReverseKey, cbReverse.checked ? 1 : 0);
    };
    cbReverse.addEventListener('change', cbReverseIt, true);
    cbReverse.checked = !!(+F.storage.get(cbReverseKey, 0));
    cbReverseIt()/*update in case of a forced check by a browser reload*/;
  };
}); // window.addEventListener( 'load' ...
schelte 1 week, 3 days ago

Man you are fast! It almost took me longer to just build the latest fossil sources than it took you to fix the issue. I confirm it is fixed.

drh 1 week, 3 days ago

Do I need to rebuild the Fossil on core.tcl-lang.org so that it includes Stephan's fix?

schelte 1 week, 3 days ago

I found this while testing. There have not been any actual user complaints yet. So it's not extremely urgent, but that would be much appreciated. Thanks.

drh 1 week, 3 days ago

Done

schelte 1 week, 3 days ago

Works. Thanks again to both of you for the fast action.

Keyboard Shortcuts

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