fix(ui): don't reset regex selection

Fixes #2520
This commit is contained in:
Łukasz Mierzwa
2020-12-08 11:09:04 +00:00
committed by Łukasz Mierzwa
parent 7b86c6bcff
commit 3febf7d0a2
3 changed files with 8 additions and 4 deletions

View File

@@ -1,5 +1,11 @@
# Changelog
## [Unreleased]
### Fixed
- Don't reset regex toggle when adding new silence labels #2520
## v0.77
### Fixed

View File

@@ -102,14 +102,14 @@ describe("<LabelValueInput />", () => {
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", () => {

View File

@@ -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