Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Say which index column is sorted
| -rw-r--r-- | source/ui-repolist.c | 7 | |
| -rwxr-xr-x | tests/t0101-index.sh | 13 |
2 files changed, 19 insertions, 1 deletion
diff --git a/source/ui-repolist.c b/source/ui-repolist.c index 3eb9375..4f79f70 100644 --- a/source/ui-repolist.c +++ b/source/ui-repolist.c @@ -192,7 +192,12 @@ static int any_repos_under_url(void) */ static void print_column_header(const char *title, const char *column, const char *currenturl) { - htmlf("<th class='left col-%s' scope='col'><a href='", column); + htmlf("<th class='left col-%s' scope='col'", column); + // Idle puts the latest change first, which is the shortest idle time, + // so every column the index sorts by runs ascending. + if (ctx.qry.sort && !strcmp(ctx.qry.sort, column)) + html(" aria-sort='ascending'"); + html("><a href='"); html_attr(currenturl); htmlf("?s=%s", column); if (ctx.qry.search) { diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index fcf873b..be947af 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh @@ -77,6 +77,19 @@ test_expect_success 'the index sorts by a column on request' ' done ' +# Only the heading of the column the index is sorted by tells a screen reader +# so. Idle lists the latest change first, so it is ascending like the rest. +test_expect_success 'the sorted column heading says which way it runs' ' + for s in name desc owner idle + do + cgit_query "s=$s" >tmp && + grep "<th class=.left col-$s. scope=.col. aria-sort=.ascending.>" tmp && + test $(grep -o "aria-sort" tmp | wc -l) = 1 || return 1 + done && + cgit_url "" >tmp && + ! grep "aria-sort" tmp +' + # A scan has no cgitrc order for the index to keep, so it lists what it finds # by path whatever order the directory hands back, comparing names the way # case-sensitive-sort tells the index to. |
