From 3febf7d0a2955bb14fd961fe9e8b2a9fc417328b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Tue, 8 Dec 2020 11:09:04 +0000 Subject: [PATCH] fix(ui): don't reset regex selection Fixes #2520 --- CHANGELOG.md | 6 ++++++ .../SilenceModal/SilenceMatch/LabelValueInput.test.tsx | 4 ++-- .../SilenceModal/SilenceMatch/LabelValueInput.tsx | 2 -- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b336dde03..a022af17a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Fixed + +- Don't reset regex toggle when adding new silence labels #2520 + ## v0.77 ### Fixed diff --git a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.test.tsx b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.test.tsx index d42db61c5..82839ee28 100644 --- a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.test.tsx +++ b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.test.tsx @@ -102,14 +102,14 @@ describe("", () => { expect(matcher.isRegex).toBe(false); }); - it("selecting one option when matcher.isRegex=true changes it back to false", () => { + it("selecting one option when matcher.isRegex=true doesn't change it back to false", () => { matcher.isRegex = true; const tree = MountedLabelValueInput(true); tree.find("input").simulate("change", { target: { value: "f" } }); expect(matcher.isRegex).toBe(true); const options = tree.find("div.react-select__option"); options.at(0).simulate("click"); - expect(matcher.isRegex).toBe(false); + expect(matcher.isRegex).toBe(true); }); it("selecting multiple options forces matcher.isRegex=true", () => { diff --git a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.tsx b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.tsx index 90b24e2a0..41d2729a5 100644 --- a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.tsx +++ b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.tsx @@ -101,8 +101,6 @@ const LabelValueInput: FC<{ // force regex if we have multiple values if (matcher.values.length > 1 && matcher.isRegex === false) { matcher.isRegex = true; - } else if (matcher.values.length === 1 && matcher.isRegex === true) { - matcher.isRegex = false; } }} hideSelectedOptions