informatics-isi-edu / chaise

An adaptive user interface for the Deriva platform.
https://www.isi.edu/isr/
Apache License 2.0
9 stars 6 forks source link

Pagination drops descending sort #1985

Open karlcz opened 4 years ago

karlcz commented 4 years ago

Go to synapse prod site.

While logged in as a project user, use navbar Browse -> Zebrafish Subjects. Then, use the next button. I see the browser location go through these states:

However, using the browser network request console, it seems to me that the second page request doesn't send the ::desc:: flag in the sort modifer to ermrest, so it gets a different page than intended:

.../attributegroup/M:=Zebrafish:Subject/...@sort(RMT,RID::desc::)@after(2020-07-23T15%3A21%3A07.306847-07%3A00,1-1T7E)?limit=11

RFSH commented 4 years ago

This is happening because of the combination of weird behavior of column_order and sort modifiers on the page. In ermrestjs#823 we discussed how the current logic is flawed and we should fix it. Based on the current implementation, what's displayed in the URL is not exactly what we will send to ermrest and we want to change this.

The following is why this bug is happening:

After navigating to a page with sort modifiers, chaise will try to apply column_order logic to each individual column in your given sort modifier (this is something that we want to change). In this table, RMT has the following column_order:

  "tag:isrd.isi.edu,2016:column-display": {
    "*": {
      "column_order": [
        {
          "column": "RMT",
          "descending": true
        }
      ]
    }
  }

So it will reverse the order of the RMT sort modifier that you have in the URL. There's no column_order definition for RID so we will use it as is. And therefore the @sort(RMT::desc::,RID::desc::) will turn into @sort(RMT,RID::desc::) when sending the request to ermrest.

karlcz commented 4 years ago

Note, however, that this doesn't happen for the initial page load. It doesn't flip direction of the sort until the first click of [next].