Sharing dialog: make autocomplete sorting case insensitive#3889
Conversation
|
@MorrisJobke, thanks for your PR! By analyzing the history of the files in this pull request, we identified @blizzz, @rullzer and @tomneedham to be potential reviewers. |
|
I tested this and it works 👍 |
Sharing dialog: Names sorting is case sensitive: adding tests #25971 Signed-off-by: Morris Jobke <hey@morrisjobke.de>
fa015d6 to
31fa2f7
Compare
|
|
||
| if (suggestions.length > 0) { | ||
| suggestions.sort(function (a, b) { | ||
| return OC.Util.naturalSortCompare(a.label, b.label); |
There was a problem hiding this comment.
This is wrong, the list is sorted on php, when that behaves incorrect we need to fix it there. Otherwise each page is sorted correctly, while the results should be on different pages.
There was a problem hiding this comment.
My suggestion would be:
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php
index a281572ad5..dfbd995fb2 100644
--- a/lib/private/User/Database.php
+++ b/lib/private/User/Database.php
@@ -193,7 +193,7 @@ class Database extends Backend implements IUserBackend {
$displayNames = array();
$query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
- . $searchLike .' ORDER BY `uid` ASC', $limit, $offset);
+ . $searchLike .' ORDER BY LOWER(`displayname`), LOWER(`uid`) ASC', $limit, $offset);
$result = $query->execute($parameters);
while ($row = $result->fetchRow()) {
$displayNames[$row['uid']] = $row['displayname'];
@@ -279,7 +279,7 @@ class Database extends Backend implements IUserBackend {
$searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)';
}
- $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset);
+ $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY LOWER(`uid`) ASC', $limit, $offset);
$result = $query->execute($parameters);
$users = array();
while ($row = $result->fetchRow()) {
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index 3d016700ee..77741efcc7 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -254,7 +254,7 @@ class Manager extends PublicEmitter implements IUserManager {
* @var \OC\User\User $a
* @var \OC\User\User $b
*/
- return strcmp($a->getDisplayName(), $b->getDisplayName());
+ return strcmp(strtolower($a->getDisplayName()), strtolower($b->getDisplayName()));
});
return $users;
}|
@nickvergessen I fixed it according to your recommendation. Only drawback with that: Groups are not sorted within the users list, but they are just concatenated at the end of the list. |
|
Yeah, but thats intentional I think |
| "shareWith": "Petra" | ||
| } | ||
| } | ||
| ])).toEqual(true); |
There was a problem hiding this comment.
Test fails with
PhantomJS 2.1.1 (Linux 0.0.0) OC.Share.ShareDialogView autocompletion of users is sorted naturally FAILED
Expected false to equal true.
core/js/tests/specs/sharedialogviewSpec.js:565:15
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
8903546 to
dbaebc5
Compare
cc @nextcloud/javascript @nextcloud/sharing for review