Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit46360a7

Browse files
authored
fix(b-table): fix sorting for negative numeric string (#7134)
1 parentfd586c0 commit46360a7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎src/components/table/helpers/default-sort-compare.spec.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,18 @@ describe('table/helpers/default-sort-compare', () => {
109109
expect(defaultSortCompare(x,w,optionsNullLast)).toBe(-1)
110110
expect(defaultSortCompare(w,x,optionsNullLast)).toBe(1)
111111
})
112+
113+
it('sorts numeric string correctly',async()=>{
114+
constoptions={sortBy:'a',numeric:true}
115+
expect(defaultSortCompare({a:'1'},{a:'2'},options)).toBe(-1)
116+
expect(defaultSortCompare({a:'2'},{a:'1'},options)).toBe(1)
117+
expect(defaultSortCompare({a:'1'},{a:'1'},options)).toBe(0)
118+
expect(defaultSortCompare({a:'-1'},{a:'1'},options)).toBe(-1)
119+
expect(defaultSortCompare({a:'1'},{a:'-1'},options)).toBe(1)
120+
expect(defaultSortCompare({a:'0'},{a:'0'},options)).toBe(0)
121+
expect(defaultSortCompare({a:'1.234'},{a:'1.567'},options)).toBe(-1)
122+
expect(defaultSortCompare({a:'1.561'},{a:'1.234'},options)).toBe(1)
123+
expect(defaultSortCompare({a:'-10'},{a:'-100'},options)).toBe(1)
124+
expect(defaultSortCompare({a:'-20'},{a:'-30'},options)).toBe(1)
125+
})
112126
})

‎src/constants/regex.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const RX_HASH_ID = /^#[A-Za-z]+[\w\-:.]*$/
99
exportconstRX_HTML_TAGS=/(<([^>]+)>)/gi
1010
exportconstRX_HYPHENATE=/\B([A-Z])/g
1111
exportconstRX_LOWER_UPPER=/([a-z])([A-Z])/g
12-
exportconstRX_NUMBER=/^[0-9]*\.?[0-9]+$/
12+
exportconstRX_NUMBER=/^[-]?[0-9]*\.?[0-9]+$/
1313
exportconstRX_PLUS=/\+/g
1414
exportconstRX_REGEXP_REPLACE=/[-/\\^$*+?.()|[\]{}]/g
1515
exportconstRX_SPACES=/[\s\uFEFF\xA0]+/g

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp