Postgres/MySQL: Fixes issue with toggle query editor mode (#35890)

* Postgres/MySQL: Fixes issue with toggle query editor mode

* PostGres/MySQL: Use $evalAsync instead of manual $digest

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
Torkel Ödegaard 2021-06-17 18:27:13 +02:00 committed by GitHub
parent fe61d20794
commit eea3ea9755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -164,12 +164,20 @@ export class MysqlQueryCtrl extends QueryCtrl {
icon: 'exclamation-triangle',
yesText: 'Switch',
onConfirm: () => {
this.target.rawQuery = !this.target.rawQuery;
// This could be called from React, so wrap in $evalAsync.
// Will then either run as part of the current digest cycle or trigger a new one.
this.$scope.$evalAsync(() => {
this.target.rawQuery = !this.target.rawQuery;
});
},
})
);
} else {
this.target.rawQuery = !this.target.rawQuery;
// This could be called from React, so wrap in $evalAsync.
// Will then either run as part of the current digest cycle or trigger a new one.
this.$scope.$evalAsync(() => {
this.target.rawQuery = !this.target.rawQuery;
});
}
}

View File

@ -196,12 +196,20 @@ export class PostgresQueryCtrl extends QueryCtrl {
icon: 'exclamation-triangle',
yesText: 'Switch',
onConfirm: () => {
this.target.rawQuery = !this.target.rawQuery;
// This could be called from React, so wrap in $evalAsync.
// Will then either run as part of the current digest cycle or trigger a new one.
this.$scope.$evalAsync(() => {
this.target.rawQuery = !this.target.rawQuery;
});
},
})
);
} else {
this.target.rawQuery = !this.target.rawQuery;
// This could be called from React, so wrap in $evalAsync.
// Will then either run as part of the current digest cycle or trigger a new one.
this.$scope.$evalAsync(() => {
this.target.rawQuery = !this.target.rawQuery;
});
}
}