File tree Expand file tree Collapse file tree 2 files changed +15
-31
lines changed Expand file tree Collapse file tree 2 files changed +15
-31
lines changed Original file line number Diff line number Diff line change @@ -2,45 +2,30 @@ import tippy from 'tippy.js';
2
2
3
3
const klass = 'has-error' ;
4
4
5
- export function error ( node : HTMLElement , content ?: string ) {
6
- let shown = false ;
7
-
5
+ export function error ( node : HTMLElement , initialError ?: string ) {
8
6
const t = tippy ( node , {
9
7
placement : 'right' ,
10
8
theme : 'light-red border' ,
11
- showOnCreate : false ,
12
- onShow : ( ) => {
13
- shown = true ;
14
- } ,
9
+ trigger : 'manual' ,
10
+ hideOnClick : false ,
11
+ interactive : true ,
15
12
} ) ;
16
13
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 ( ) ;
38
18
node . classList . add ( klass ) ;
39
19
} else {
40
- t . disable ( ) ;
20
+ t . hide ( ) ;
41
21
node . classList . remove ( klass ) ;
42
22
}
43
23
}
44
24
45
- return { update } ;
25
+ update ( initialError ) ;
26
+
27
+ return {
28
+ update,
29
+ destroy : t . destroy ,
30
+ } ;
46
31
}
Original file line number Diff line number Diff line change 7
7
import AccessControlSection from ' ./AccessControlSection.svelte' ;
8
8
import InfoSection from ' ./InfoSection.svelte' ;
9
9
import ExpandableToggleRadio from ' ../common/ExpandableToggleRadio.svelte' ;
10
- import ToggleRadio from ' ../common/inputs/ToggleRadio.svelte' ;
11
10
import OPIcon from ' ../common/icons/OPIcon.svelte' ;
12
11
import { error } from ' ../common/error-tooltip' ;
13
12
import { resizeToFit } from ' ../common/resize-to-fit' ;
You can’t perform that action at this time.
0 commit comments