Skip to content

Commit 6cb284a

Browse files
authored
fix: dropdown options of select fields use the full available width (#2508)
fixes #2494
1 parent 831cb09 commit 6cb284a

File tree

10 files changed

+112
-75
lines changed

10 files changed

+112
-75
lines changed
Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
<mat-form-field>
22
<mat-label>{{ label }}</mat-label>
3-
<app-basic-autocomplete
4-
#autocomplete
5-
[formControl]="form"
6-
[multi]="multi"
7-
[options]="options"
8-
[optionToString]="enumValueToString"
9-
[createOption]="createNewOption"
10-
></app-basic-autocomplete>
3+
<div class="autocomplete-container">
4+
<app-basic-autocomplete
5+
#autocomplete
6+
[formControl]="form"
7+
[multi]="multi"
8+
[options]="options"
9+
[optionToString]="enumValueToString"
10+
[createOption]="createNewOption"
11+
></app-basic-autocomplete>
1112

12-
<fa-icon
13-
*ngIf="form.enabled"
14-
icon="caret-down"
15-
class="form-field-icon-suffix"
16-
(click)="autocomplete.showAutocomplete()"
17-
matIconSuffix
18-
></fa-icon>
13+
<div class="icon-container">
14+
<fa-icon
15+
*ngIf="form.enabled"
16+
icon="caret-down"
17+
class="form-field-icon-suffix"
18+
(click)="autocomplete.showAutocomplete()"
19+
matIconSuffix
20+
></fa-icon>
1921

20-
<fa-icon
21-
*ngIf="form.enabled && !!createNewOption && canEdit"
22-
class="form-field-icon-suffix"
23-
matIconSuffix
24-
(click)="openSettings($event)"
25-
icon="wrench"
26-
></fa-icon>
22+
<fa-icon
23+
*ngIf="form.enabled && !!createNewOption && canEdit"
24+
class="form-field-icon-suffix"
25+
matIconSuffix
26+
(click)="openSettings($event)"
27+
icon="wrench"
28+
></fa-icon>
29+
</div>
2730

28-
<mat-error *ngIf="form.errors">
29-
<app-error-hint [form]="form"></app-error-hint>
30-
</mat-error>
31+
<mat-error *ngIf="form.errors">
32+
<app-error-hint [form]="form"></app-error-hint>
33+
</mat-error>
34+
</div>
3135
</mat-form-field>

src/app/core/basic-datatypes/configurable-enum/enum-dropdown/enum-dropdown.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import { OkButton } from "../../../common-components/confirmation-dialog/confirm
2020
@Component({
2121
selector: "app-enum-dropdown",
2222
templateUrl: "./enum-dropdown.component.html",
23-
styleUrls: ["./enum-dropdown.component.scss"],
23+
styleUrls: [
24+
"./enum-dropdown.component.scss",
25+
"../../../common-components/basic-autocomplete/basic-autocomplete-dropdown.component.scss",
26+
],
2427
standalone: true,
2528
imports: [
2629
MatSelectModule,

src/app/core/basic-datatypes/discrete/discrete-import-config/discrete-import-config.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<mat-dialog-content>
2-
<table>
2+
<table class="mapping-table">
33
<tr>
44
<th i18n="Import mapping header">Imported values</th>
55
<th i18n="Import mapping header">Assigned values</th>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.mapping-table {
2+
width: 100%;
3+
max-width: 800px;
4+
}
5+
6+
.mapping-table th {
7+
text-align: left;
8+
}
9+
10+
:host ::ng-deep mat-form-field {
11+
width: 100%;
12+
max-width: 400px;
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.autocomplete-container {
2+
position: relative;
3+
}
4+
5+
.icon-container {
6+
position: absolute;
7+
top: 0;
8+
right: 0;
9+
}

src/app/core/common-components/basic-autocomplete/basic-autocomplete.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[hidden]="focused || display === 'none'"
55
[disabled]="_disabled"
66
matInput
7-
style="text-overflow: ellipsis"
7+
style="text-overflow: ellipsis; width: calc(100% - 50px)"
88
(focusin)="showAutocomplete()"
99
(focusout)="showAutocomplete()"
1010
[value]="displayText"

src/app/core/common-components/entity-select/entity-select.component.html

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
<mat-form-field>
22
<mat-label>{{ label }}</mat-label>
3+
<div class="autocomplete-container">
4+
<app-basic-autocomplete
5+
#autocomplete
6+
[formControl]="form"
7+
[valueMapper]="entityToId"
8+
[optionToString]="accessor"
9+
(autocompleteFilterChange)="recalculateMatchingInactive($event)"
10+
[multi]="multi"
11+
[display]="showEntities ? 'chips' : 'none'"
12+
[options]="availableOptions | async"
13+
[placeholder]="(loading | async) ? loadingPlaceholder : placeholder"
14+
[createOption]="createNewEntity"
15+
>
16+
<ng-template let-item>
17+
<app-entity-block
18+
style="margin: auto"
19+
[entityToDisplay]="item"
20+
[linkDisabled]="form.enabled"
21+
></app-entity-block>
22+
</ng-template>
323

4-
<app-basic-autocomplete
5-
#autocomplete
6-
[formControl]="form"
7-
[valueMapper]="entityToId"
8-
[optionToString]="accessor"
9-
(autocompleteFilterChange)="recalculateMatchingInactive($event)"
10-
[multi]="multi"
11-
[display]="showEntities ? 'chips' : 'none'"
12-
[options]="availableOptions | async"
13-
[placeholder]="(loading | async) ? loadingPlaceholder : placeholder"
14-
[createOption]="createNewEntity"
15-
>
16-
<ng-template let-item>
17-
<app-entity-block
18-
style="margin: auto"
19-
[entityToDisplay]="item"
20-
[linkDisabled]="form.enabled"
21-
></app-entity-block>
22-
</ng-template>
23-
24-
<ng-container autocompleteFooter *ngIf="currentlyMatchingInactive > 0">
25-
<mat-slide-toggle
26-
[checked]="includeInactive"
27-
(toggleChange)="toggleIncludeInactive()"
28-
i18n="Label for checkbox|e.g. include inactive children"
29-
>Also show {{ currentlyMatchingInactive }} inactive
30-
</mat-slide-toggle>
31-
</ng-container>
32-
</app-basic-autocomplete>
33-
34-
<fa-icon
35-
*ngIf="form.enabled"
36-
icon="caret-down"
37-
class="form-field-icon-suffix"
38-
(click)="autocomplete.showAutocomplete()"
39-
matIconSuffix
40-
></fa-icon>
41-
24+
<ng-container autocompleteFooter *ngIf="currentlyMatchingInactive > 0">
25+
<mat-slide-toggle
26+
[checked]="includeInactive"
27+
(toggleChange)="toggleIncludeInactive()"
28+
i18n="Label for checkbox|e.g. include inactive children"
29+
>Also show {{ currentlyMatchingInactive }} inactive
30+
</mat-slide-toggle>
31+
</ng-container>
32+
</app-basic-autocomplete>
33+
<div class="icon-container">
34+
<fa-icon
35+
*ngIf="form.enabled"
36+
icon="caret-down"
37+
class="form-field-icon-suffix"
38+
(click)="autocomplete.showAutocomplete()"
39+
matIconSuffix
40+
></fa-icon>
41+
</div>
42+
</div>
4243
<mat-error *ngIf="form.errors">
4344
<app-error-hint [form]="form"></app-error-hint>
4445
</mat-error>

src/app/core/common-components/entity-select/entity-select.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import { EntityRegistry } from "../../entity/database-entity.decorator";
2424
@Component({
2525
selector: "app-entity-select",
2626
templateUrl: "./entity-select.component.html",
27-
styleUrls: ["./entity-select.component.scss"],
27+
styleUrls: [
28+
"./entity-select.component.scss",
29+
"../../common-components/basic-autocomplete/basic-autocomplete-dropdown.component.scss",
30+
],
2831
imports: [
2932
MatFormFieldModule,
3033
NgIf,

src/app/core/import/import-column-mapping/import-column-mapping.component.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ describe("ImportColumnMappingComponent", () => {
3939
genderColumn.propertyName = "category";
4040
await component.openMappingComponent(genderColumn);
4141

42-
expect(openSpy).toHaveBeenCalledWith(DiscreteImportConfigComponent, {
43-
data: {
44-
col: genderColumn,
45-
values: ["male", "female"],
46-
entityType: TestEntity,
47-
},
48-
disableClose: true,
49-
});
42+
expect(openSpy).toHaveBeenCalledWith(
43+
DiscreteImportConfigComponent,
44+
jasmine.objectContaining({
45+
data: {
46+
col: genderColumn,
47+
values: ["male", "female"],
48+
entityType: TestEntity,
49+
},
50+
disableClose: true,
51+
}),
52+
);
5053
});
5154

5255
it("should emit changes after popup is closed", async () => {

src/app/core/import/import-column-mapping/import-column-mapping.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class ImportColumnMappingComponent implements OnChanges {
110110
values: [...uniqueValues],
111111
entityType: this.entityCtor,
112112
},
113+
width: "80vw",
113114
disableClose: true,
114115
})
115116
.afterClosed()

0 commit comments

Comments
 (0)