mirror of
https://github.com/gosticks/web.git
synced 2026-10-06 14:47:32 +00:00
Merge pull request #98 from pi-hole/fix/domain-input-empty
Don't handle empty input in DomainInput
This commit is contained in:
@@ -25,6 +25,12 @@ class DomainInput extends Component {
|
||||
e.preventDefault();
|
||||
|
||||
const domain = this.state.domain;
|
||||
|
||||
// Don't do anything for empty inputs
|
||||
if (domain.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isValid = this.props.isValid(domain);
|
||||
this.setState({ isValid });
|
||||
if (isValid) {
|
||||
|
||||
@@ -128,15 +128,15 @@ it("does not call onEnter when input is empty", () => {
|
||||
<DomainInput
|
||||
onEnter={onEnter}
|
||||
onRefresh={jest.fn()}
|
||||
isValid={isValidDomain}
|
||||
isValid={() => true}
|
||||
onValidationError={jest.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
wrapper
|
||||
.find("button")
|
||||
.find("form")
|
||||
.first()
|
||||
.simulate("click");
|
||||
.simulate("submit", { preventDefault: jest.fn() });
|
||||
|
||||
expect(onEnter).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user