mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Use unicode-aware comparisons for user-visible strings.
Summary: - Switch code that compares user strings to use localeCompare() based on Intl.Collator. - Use en-US locale for now. (Ideally should be a document property.) - Note that with this change, sorting is also becoming case-insensitive (which seems an improvement) - Updated a sorted test fixture - Updated a browser test with lots of unicode to expect different order. - Added a bit of unicode to test ordering in Reference autocomplete dropdown. Test Plan: Fixed / updated tests Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2758
This commit is contained in:
@@ -15,7 +15,7 @@ import {colors, vars} from 'app/client/ui2018/cssVars';
|
||||
import {icon} from 'app/client/ui2018/icons';
|
||||
import {menuCssClass, menuDivider, menuIcon} from 'app/client/ui2018/menus';
|
||||
import {CellValue} from 'app/common/DocActions';
|
||||
import {nativeCompare} from 'app/common/gutil';
|
||||
import {localeCompare} from 'app/common/gutil';
|
||||
import {Computed, dom, input, makeTestId, Observable, styled} from 'grainjs';
|
||||
import escapeRegExp = require('lodash/escapeRegExp');
|
||||
import identity = require('lodash/identity');
|
||||
@@ -63,7 +63,7 @@ export function columnFilterMenu({ columnFilter, valueCounts, doSave, onClose }:
|
||||
const filteredValues = Computed.create(null, openSearch, searchValueObs, (_use, isOpen, searchValue) => {
|
||||
const searchRegex = new RegExp(escapeRegExp(searchValue), 'i');
|
||||
return valueCountArr.filter(([key]) => !isOpen || searchRegex.test(key as string))
|
||||
.sort((a, b) => nativeCompare(a[1].label, b[1].label));
|
||||
.sort((a, b) => localeCompare(a[1].label, b[1].label));
|
||||
});
|
||||
|
||||
let searchInput: HTMLInputElement;
|
||||
|
||||
Reference in New Issue
Block a user