Skip to content

Commit 6789092

Browse files
CoveMBericglau
andauthored
Better input error UI (#557)
Co-authored-by: Eric Lau <[email protected]>
1 parent 1ccba07 commit 6789092

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

packages/ui/src/common/error-tooltip.ts

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,30 @@ import tippy from 'tippy.js';
22

33
const klass = 'has-error';
44

5-
export function error(node: HTMLElement, content?: string) {
6-
let shown = false;
7-
5+
export function error(node: HTMLElement, initialError?: string) {
86
const t = tippy(node, {
97
placement: 'right',
108
theme: 'light-red border',
11-
showOnCreate: false,
12-
onShow: () => {
13-
shown = true;
14-
},
9+
trigger: 'manual',
10+
hideOnClick: false,
11+
interactive: true,
1512
});
1613

17-
t.disable();
18-
update(content);
19-
20-
function update(content?: string) {
21-
if (content) {
22-
t.setContent(content);
23-
24-
if (!t.state.isEnabled) {
25-
shown = false;
26-
t.enable();
27-
if (document.activeElement !== node) {
28-
t.show();
29-
} else {
30-
setTimeout(() => {
31-
if (!shown) {
32-
t.show();
33-
}
34-
}, 1000);
35-
}
36-
}
37-
14+
function update(newError?: string) {
15+
if (newError) {
16+
t.setContent(newError);
17+
t.show();
3818
node.classList.add(klass);
3919
} else {
40-
t.disable();
20+
t.hide();
4121
node.classList.remove(klass);
4222
}
4323
}
4424

45-
return { update };
25+
update(initialError);
26+
27+
return {
28+
update,
29+
destroy: t.destroy,
30+
};
4631
}

packages/ui/src/solidity/StablecoinControls.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import AccessControlSection from './AccessControlSection.svelte';
88
import InfoSection from './InfoSection.svelte';
99
import ExpandableToggleRadio from '../common/ExpandableToggleRadio.svelte';
10-
import ToggleRadio from '../common/inputs/ToggleRadio.svelte';
1110
import OPIcon from '../common/icons/OPIcon.svelte';
1211
import { error } from '../common/error-tooltip';
1312
import { resizeToFit } from '../common/resize-to-fit';

0 commit comments

Comments
 (0)