Skip to content

Commit

Permalink
Fix layout of additional languages dropdown in MultiLanguageTextField…
Browse files Browse the repository at this point in the history
…Component [notarize]
  • Loading branch information
tkleinke committed Mar 26, 2023
1 parent c004afa commit 983bfb7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class MultiLanguageTextFieldComponent implements OnChanges {
public selectedText: string;
public shownAdditionalLanguage: Language|undefined;
public focused: boolean = false;
public additionalLanguagesDropdownOpened: boolean = false;


public isFilledIn = (languageCode: string) => this.multiLanguageText?.[languageCode] !== undefined;
Expand Down Expand Up @@ -77,6 +78,16 @@ export class MultiLanguageTextFieldComponent implements OnChanges {
}


public onAdditionalLanguagesDropdownMenuToggled(opened: boolean) {

this.additionalLanguagesDropdownOpened = opened;

if (this.additionalLanguagesDropdownOpened && this.shownAdditionalLanguage) {
this.selectLanguage(this.shownAdditionalLanguage);
}
}


public selectLanguage(language: Language) {

if (this.additionalLanguages.includes(language)) this.shownAdditionalLanguage = language;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@
(focus)="focused = true">{{language.label}}</a>
</li>
<li *ngIf="additionalLanguages?.length > 0" class="nav-item additional-languages-dropdown"
ngbDropdown placement="bottom-right" role="group">
<a class="nav-link" [class.active]="shownAdditionalLanguage.code === selectedLanguage"
[class.filled-in]="isFilledIn(shownAdditionalLanguage.code)" ngbDropdownToggle>
{{shownAdditionalLanguage.label}}
</a>
<div class="additional-languages-dropdown-menu dropdown-menu" ngbDropdownMenu>
ngbDropdown placement="bottom-right" role="group"
(openChange)="onAdditionalLanguagesDropdownMenuToggled($event)">
<a class="nav-link"
[class.active]="shownAdditionalLanguage.code === selectedLanguage || additionalLanguagesDropdownOpened"
[class.filled-in]="isFilledIn(shownAdditionalLanguage.code)" ngbDropdownToggle>
{{shownAdditionalLanguage.label}}
</a>
<div class="additional-languages-dropdown-menu dropdown-menu" ngbDropdownMenu>
<div class="additional-languages-dropdown-list">
<button *ngFor="let language of additionalLanguages"
class="dropdown-item"
(click)="selectLanguage(language)">
{{language.label}}
</button>
</div>
</div>
</div>
</li>
</ul>
<input *ngIf="!multiLine" #inputField [(ngModel)]="selectedText"
Expand Down

0 comments on commit 983bfb7

Please sign in to comment.