@@ -22,7 +22,9 @@ const Applications = () => {
22
22
const [ open , setOpen ] = useState < boolean > ( false ) ;
23
23
const [ index , setIndex ] = useState < number > ( 0 ) ;
24
24
const [ app , setApp ] = useState < string > ( '' ) ;
25
- const delRef = useRef < any > ( null ) ;
25
+
26
+ // Dynamic refs
27
+ const delRef = useRef < any > ( [ ] ) ;
26
28
27
29
useEffect ( ( ) => {
28
30
getApplications ( ) ;
@@ -36,7 +38,7 @@ const Applications = () => {
36
38
37
39
// Handle clicks on Application cards
38
40
const handleClick = ( event : ClickEvent , selectedApp : string , i : number ) => {
39
- if ( ! delRef . current . contains ( event . target ) ) {
41
+ if ( delRef . current [ i ] && ! delRef . current [ i ] . contains ( event . target ) ) {
40
42
setIndex ( i ) ;
41
43
setApp ( selectedApp ) ;
42
44
setOpen ( true ) ;
@@ -52,7 +54,10 @@ const Applications = () => {
52
54
backgroundColor : 'rgba(33, 34, 41, 0.2)' ,
53
55
border : '3px ridge #808080' ,
54
56
boxShadow : '0 10px 10px rgba(0,0,0,0.5)' ,
55
- '&:hover, &.Mui-focusVisible' : { color : 'white' , background : 'rgba(33, 34, 41, 1.2)' } ,
57
+ '&:hover, &.Mui-focusVisible' : {
58
+ color : 'white' ,
59
+ background : 'rgba(33, 34, 41, 1.2)' ,
60
+ } ,
56
61
} ,
57
62
hover : {
58
63
position : 'relative' ,
@@ -91,7 +96,7 @@ const Applications = () => {
91
96
< CardHeader
92
97
avatar = {
93
98
< IconButton
94
- ref = { delRef }
99
+ ref = { element => ( delRef . current [ i ] = element ) }
95
100
className = { classes . hover }
96
101
aria-label = "Delete"
97
102
onClick = { event => confirmDelete ( event , app [ 0 ] , i ) }
@@ -115,8 +120,3 @@ const Applications = () => {
115
120
} ;
116
121
117
122
export default Applications ;
118
-
119
- //name, desc, creation date
120
- // three cards a row, same width
121
- // move trash can
122
- //change the font
0 commit comments