Skip to content

Commit

Permalink
Return key trigger submit event
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Aug 12, 2023
1 parent e1aad65 commit 1904133
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
EventEmitter,
forwardRef,
Input,
NgZone,
Output,
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
Expand Down Expand Up @@ -83,7 +84,8 @@ export class XInputComponent implements AfterViewInit, ControlValueAccessor {

constructor(
private store: Store<RootState>,
private environmentService: EnvironmentService
private environmentService: EnvironmentService,
private zone: NgZone
) {}
ngAfterViewInit(): void {
this.ready = true;
Expand Down Expand Up @@ -126,7 +128,16 @@ export class XInputComponent implements AfterViewInit, ControlValueAccessor {
return [
inputTheme,
placeholder(this.placeholder),
keymap.of([...completionKeymap]),
keymap.of([
{
key: 'Enter',
run: () => {
this.zone.run(() => this.submitChange.emit());
return false;
},
},
...completionKeymap,
]),
autocompletion({
override: [
(ctx: CompletionContext) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class ScriptEvaluator {
} catch (err) {
worker.postMessage({
type: getErrorEvent(key),
payload: { id, error: err },
payload: { id, error: `${(err as any).message ?? err}` },
});
}
})();
Expand Down

0 comments on commit 1904133

Please sign in to comment.