Skip to content

Commit

Permalink
fix(core): add option to set a custom width to Combobox (#12594)
Browse files Browse the repository at this point in the history
Co-authored-by: deno <[email protected]>
  • Loading branch information
InnaAtanasova and droshev authored Oct 21, 2024
1 parent cf94fe7 commit ccb85f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions libs/core/combobox/combobox.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[triggers]="triggers"
[disabled]="disabled || readOnly"
[maxWidth]="640"
[style.width]="width && '100%'"
[closeOnOutsideClick]="closeOnOutsideClick"
>
<fd-popover-control>
Expand Down
7 changes: 6 additions & 1 deletion libs/core/combobox/combobox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ let comboboxUniqueId = 0;
host: {
'[class.fd-combobox-custom-class]': 'true',
'[class.fd-combobox-input]': 'true',
'[class.fd-combobox-custom-class--mobile]': 'mobile'
'[class.fd-combobox-custom-class--mobile]': 'mobile',
'[style.width]': 'width'
},
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down Expand Up @@ -244,6 +245,10 @@ export class ComboboxComponent<T = any>
@Input()
maxHeight = '50vh';

/** Custom width of the control. */
@Input()
width: Nullable<string>;

/** Search function to execute when the Enter key is pressed on the main input. */
@Input()
searchFn: () => void;
Expand Down
17 changes: 16 additions & 1 deletion libs/docs/core/combobox/examples/combobox-example.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<div class="examples-column">
<div fd-form-item>
<label fd-form-label for="comboboxID1">Standard</label>
<label fd-form-label for="comboboxID1">Standard with custom width</label>
<fd-combobox
inputId="comboboxID1"
ariaLabel="Standard"
maxHeight="250px"
width="300px"
placeholder="Type some text..."
[dropdownValues]="fruits"
[(ngModel)]="searchTermOne"
Expand Down Expand Up @@ -87,4 +88,18 @@
</fd-combobox>
</div>
<small>Search Term: {{ searchTermSix }}</small>

<div fd-form-item>
<label fd-form-label for="comboboxID1">Standard</label>
<fd-combobox
inputId="comboboxID1"
ariaLabel="Standard"
maxHeight="250px"
placeholder="Type some text..."
[dropdownValues]="fruits"
[(ngModel)]="searchTermOne"
>
</fd-combobox>
</div>
<small>Search Term: {{ searchTermOne }}</small>
</div>

0 comments on commit ccb85f3

Please sign in to comment.