Skip to content

Commit 25fb5b1

Browse files
committed
[bug] fix add and edit modals not closing when using keyboard shortcuts
1 parent 95da1a8 commit 25fb5b1

File tree

1 file changed

+50
-16
lines changed

1 file changed

+50
-16
lines changed

‎src/js/keyboard.js‎

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,31 @@ var keyboard = (function(){
5050
window.addEventListener("keydown",function(event){
5151
// ctrl+alt+a
5252
if(event.ctrlKey&&event.altKey&&event.keyCode==65){
53+
if(state.get.current().menu){
54+
menu.close();
55+
};
56+
if(state.get.current().modal&&!state.get.current().link.add){
57+
modal.close();
58+
};
59+
if(state.get.current().link.edit){
60+
link.edit.item.close();
61+
modal.close();
62+
shade.close();
63+
data.save();
64+
};
65+
if(state.get.current().group.edit){
66+
link.edit.group.close();
67+
modal.close();
68+
shade.close();
69+
data.save();
70+
};
5371
if(state.get.current().group.add){
5472
link.add.group.close();
73+
modal.close();
74+
shade.close();
75+
data.save();
5576
};
5677
if(!state.get.current().link.add){
57-
if(state.get.current().menu){
58-
menu.close();
59-
};
60-
if(state.get.current().modal){
61-
modal.close();
62-
};
6378
link.add.item.open();
6479
};
6580
};
@@ -70,16 +85,31 @@ var keyboard = (function(){
7085
window.addEventListener("keydown",function(event){
7186
// ctrl+alt+g
7287
if(event.ctrlKey&&event.altKey&&event.keyCode==71){
88+
if(state.get.current().menu){
89+
menu.close();
90+
};
91+
if(state.get.current().modal&&!state.get.current().group.add){
92+
modal.close();
93+
};
94+
if(state.get.current().link.edit){
95+
link.edit.item.close();
96+
modal.close();
97+
shade.close();
98+
data.save();
99+
};
73100
if(state.get.current().link.add){
74101
link.add.item.close();
102+
modal.close();
103+
shade.close();
104+
data.save();
105+
};
106+
if(state.get.current().group.edit){
107+
link.edit.group.close();
108+
modal.close();
109+
shade.close();
110+
data.save();
75111
};
76112
if(!state.get.current().group.add){
77-
if(state.get.current().menu){
78-
menu.close();
79-
};
80-
if(state.get.current().modal){
81-
modal.close();
82-
};
83113
link.add.group.open();
84114
};
85115
};
@@ -106,22 +136,26 @@ var keyboard = (function(){
106136
modal.close();
107137
shade.close();
108138
data.save();
109-
}elseif(state.get.current().link.add){
139+
};
140+
if(state.get.current().link.add){
110141
link.add.item.close();
111142
modal.close();
112143
shade.close();
113144
data.save();
114-
}elseif(state.get.current().group.edit){
145+
};
146+
if(state.get.current().group.edit){
115147
link.edit.group.close();
116148
modal.close();
117149
shade.close();
118150
data.save();
119-
}elseif(state.get.current().group.add){
151+
};
152+
if(state.get.current().group.add){
120153
link.add.group.close();
121154
modal.close();
122155
shade.close();
123156
data.save();
124-
}elseif(state.get.current().modal){
157+
};
158+
if(state.get.current().modal){
125159
modal.close();
126160
shade.close();
127161
};

0 commit comments

Comments
(0)