diff --git a/libs/auth/src/angular/registration/registration-env-selector/registration-env-selector.component.html b/libs/auth/src/angular/registration/registration-env-selector/registration-env-selector.component.html index 5135fb6192..35bb4236c5 100644 --- a/libs/auth/src/angular/registration/registration-env-selector/registration-env-selector.component.html +++ b/libs/auth/src/angular/registration/registration-env-selector/registration-env-selector.component.html @@ -1,7 +1,7 @@
{{ "creatingAccountOn" | i18n }} - + - this.handleSelfHostedEnvConfigDialogResult(result, prevSelectedRegion), - ), - ); + if (selectedRegion !== Region.SelfHosted) { + this.selectedRegionChange.emit(selectedRegion); + return from(this.environmentService.setEnvironment(selectedRegion.key)); } - this.selectedRegionChange.emit(selectedRegion); - return from(this.environmentService.setEnvironment(selectedRegion.key)); + return of(null); }, ), takeUntil(this.destroy$), @@ -170,6 +169,17 @@ export class RegistrationEnvSelectorComponent implements OnInit, OnDestroy { } } + /** + * Handles the event when the select is closed. + * If the selected region is self-hosted, opens the self-hosted environment settings dialog. + */ + protected async onSelectClosed() { + if (this.selectedRegion.value === Region.SelfHosted) { + const result = await SelfHostedEnvConfigDialogComponent.open(this.dialogService); + return this.handleSelfHostedEnvConfigDialogResult(result, this.selectedRegion.value); + } + } + ngOnDestroy() { this.destroy$.next(); this.destroy$.complete(); diff --git a/libs/components/src/select/select.component.html b/libs/components/src/select/select.component.html index f334e67d69..848692526a 100644 --- a/libs/components/src/select/select.component.html +++ b/libs/components/src/select/select.component.html @@ -7,6 +7,7 @@ (blur)="onBlur()" [labelForId]="labelForId" [clearable]="false" + (close)="onClose()" appendTo="body" > diff --git a/libs/components/src/select/select.component.ts b/libs/components/src/select/select.component.ts index 2d900353a6..d189f1ab52 100644 --- a/libs/components/src/select/select.component.ts +++ b/libs/components/src/select/select.component.ts @@ -7,6 +7,8 @@ import { QueryList, Self, ViewChild, + Output, + EventEmitter, } from "@angular/core"; import { ControlValueAccessor, NgControl, Validators } from "@angular/forms"; import { NgSelectComponent } from "@ng-select/ng-select"; @@ -31,6 +33,7 @@ export class SelectComponent implements BitFormFieldControl, ControlValueAcce /** Optional: Options can be provided using an array input or using `bit-option` */ @Input() items: Option[] = []; @Input() placeholder = this.i18nService.t("selectPlaceholder"); + @Output() closed = new EventEmitter(); protected selectedValue: T; protected selectedOption: Option; @@ -156,4 +159,9 @@ export class SelectComponent implements BitFormFieldControl, ControlValueAcce private findSelectedOption(items: Option[], value: T): Option | undefined { return items.find((item) => item.value === value); } + + /**Emits the closed event. */ + protected onClose() { + this.closed.emit(); + } }