diff --git a/src/app/webide/webide.component.html b/src/app/webide/webide.component.html
index 5a2a2a6..37f1f25 100644
--- a/src/app/webide/webide.component.html
+++ b/src/app/webide/webide.component.html
@@ -3,7 +3,7 @@
class="btn btn-secondary"
[class.active]="filename === file"
[class.disabled]="filename === file"
- (click)="sendCodeContents(); selectCode(file); requestCode()"
+ (click)="tabSwitchButtonHandler(file)"
[disabled]="filename === file">
{{file}}
diff --git a/src/app/webide/webide.component.ts b/src/app/webide/webide.component.ts
index 2180d8e..a0d76bd 100644
--- a/src/app/webide/webide.component.ts
+++ b/src/app/webide/webide.component.ts
@@ -76,6 +76,14 @@ export class WebideComponent implements OnInit {
this.updateFileData(data);
}
+ tabSwitchButtonHandler(file) {
+ if (this.saveButtonState === 'DIRTY') {
+ this.sendCodeContents();
+ }
+ this.selectCode(file);
+ this.requestCode();
+ }
+
setButtonStateSaved() {
this.saveButtonState = 'SAVED';
}