lorenzofox3 / Smart-Table

Code source of Smart Table module: a table/grid for Angularjs
http://lorenzofox3.github.io/smart-table-website/
1.8k stars 513 forks source link

Alphanumeric sort unresponsive on 3rd or 4th click #820

Open risafletcher opened 6 years ago

risafletcher commented 6 years ago

Angular version 1.4.10 Smart-Table version 2.1.8

CASE: Using st-sort to sort items (alphabetically) by a string property. EXPECTED: First click: sort A -Z, Second click: Z - A, Third click: sort A - Z, Fourth click: Z - A, and so on and so forth. RESULT: First click: sort A - Z, Second click: Z - A, Third click: unresponsive (still Z - A), Fourth click: A - Z. Sometimes it stops on third, sometimes on forth. The caret icon disappears and requires another click to sort again. Is this an issue with Angular's orderBy?

A good example is the smart table docs under the 'Sort Data' section. You'll find that the table's 'first name' header has the same behavior. I'm not using a getter in my situation but the issue is the same.

MrWook commented 6 years ago

Hello @risafletcher,

this is the correct behaviour. The stSort has three states.

  1. Ascending (A-Z)
  2. Descending (Z-A)
  3. Natural (without sorting)

Probably your raw data is sorted in descending order. If you don't want to have the natural order:

You can skip the "natural order" state by adding st-skip-natural="true" as attribute of your th element.

risafletcher commented 6 years ago

@MrWook Forgot to mention that in my post. Yes, st-skip-natural is set to true. Issue persists.

MrWook commented 6 years ago

Hello @risafletcher,

my next thought would be the outdated angular version but i can't help you without an example plunk.