mirror of
1
Fork 0
forgejo/web_src/js
MisterCavespider c403e2f1cf
Fixed colour transparency regex matching in project board sorting (#22091) (#22092)
As described in the linked issue (#22091), semi-transparent UI elements
would result in JS errors due to the fact that the CSS `backgroundColor`
element was being matched by the pattern
`^rgb\((\d+),\s*(\d+),\s*(\d+)\)$`, which does not take the alpha
channel into account.

I changed the pattern to `^rgba?\((\d+),\s*(\d+),\s*(\d+).*\)$`.
This new pattern accepts both `rgb` and `rgba` tuples, and ignores the
alpha channel (that little `.*` at the end) from the sorting criteria.
The reason why I chose to ignore alpha is because when it comes to
kanban colour sorting, only the hue is important; the order of the
panels should stay the same, even if some of them are transparent.

Alternative solutions were discussed in the bug report and are included
here for completeness:
1. Change the regex from ^rgb\((\d+),\s*(\d+),\s*(\d+)\)$ to
^rgba?\((\d+),\s*(\d+),\s*(\d+)(,\s*(\d+(\.\d+)?))?\)$ (alpha channel is
a float or NaN on 5th group) and include the alpha channel in the
sorting criteria.
2. Rethink on why you're reading colours out of the CSS in the first
place, then reformat this sorting procedure.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-21 20:19:04 +08:00
..
components Fix heatmap first color being unused (#22157) 2022-12-19 16:14:49 -05:00
features Fixed colour transparency regex matching in project board sorting (#22091) (#22092) 2022-12-21 20:19:04 +08:00
markup Fix markdown anchor re-clicking (#21931) 2022-11-26 19:15:44 +08:00
modules Improvements for Content Copy (#21842) 2022-11-21 17:59:42 +08:00
standalone Add new JS linter rules (#17699) 2021-11-22 16:19:01 +08:00
test Switch from jest to vitest (#21444) 2022-10-14 21:36:16 +08:00
bootstrap.js Quick fixes monaco-editor error: "vs.editor.nullLanguage" (#21734) 2022-11-09 18:02:19 +08:00
index.js Improvements for Content Copy (#21842) 2022-11-21 17:59:42 +08:00
jquery.js Upgrade jQuery to 3.5.0, remove jQuery-Migrate, fix deprecations (#11055) 2020-04-18 18:46:29 -04:00
serviceworker.js Fix serviceworker output file and misc improvements (#11562) 2020-05-24 08:36:40 +01:00
svg.js Multiple improvements for comment edit diff (#21990) 2022-12-02 11:42:34 +02:00
svg.test.js Remove vitest globals (#21505) 2022-10-19 14:50:19 +08:00
utils.js Fixes #21895: standardize UTC tz for util tests (#21897) 2022-11-22 16:46:29 +08:00
utils.test.js Improvements for Content Copy (#21842) 2022-11-21 17:59:42 +08:00