Skip to content

Commit 6d030db

Browse files
authored
Merge branch 'master' into tabs
2 parents 7333680 + a93e3ad commit 6d030db

25 files changed

+984
-253
lines changed

package-lock.json

Lines changed: 40 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,9 @@
145145
"webpack-node-externals": "1.6.0",
146146
"whatwg-fetch": "2.0.3",
147147
"zone.js": "0.8.26"
148+
},
149+
"dependencies": {
150+
"flatpickr": "4.5.2",
151+
"ng2-flatpickr": "7.0.1"
148152
}
149153
}

src/combobox/combobox.component.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import { NG_VALUE_ACCESSOR } from "@angular/forms";
3737
tabindex="0"
3838
type="button"
3939
aria-label="close menu"
40-
aria-haspopup="true">
40+
aria-haspopup="true"
41+
(click)="toggleDropdown()">
4142
<div
4243
*ngIf="type === 'multi' && pills.length > 0"
4344
(click)="clearSelected()"
@@ -60,7 +61,6 @@ import { NG_VALUE_ACCESSOR } from "@angular/forms";
6061
</div>
6162
<input
6263
[disabled]="disabled"
63-
(click)="toggleDropdown()"
6464
(keyup)="onSearch($event.target.value)"
6565
[value]="selectedValue"
6666
class="bx--text-input"
@@ -218,7 +218,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
218218
*/
219219
ngOnChanges(changes) {
220220
if (changes.items) {
221-
this.view["updateList"](changes.items.currentValue);
221+
this.view.items = changes.items.currentValue;
222222
this.updateSelected();
223223
}
224224
}
@@ -248,15 +248,15 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
248248
this.selectedValue = "";
249249
this.propagateChangeCallback(null);
250250
}
251-
// not gaurding these since the nativeElement has to be loaded
251+
// not guarding these since the nativeElement has to be loaded
252252
// for select to even fire
253253
this.elementRef.nativeElement.querySelector("input").focus();
254254
this.closeDropdown();
255255
}
256256
this.selected.emit(event);
257-
this.view["filterBy"]("");
257+
this.view.filterBy("");
258258
});
259-
this.view["updateList"](this.items);
259+
this.view.items = this.items;
260260
// update the rest of combobox with any pre-selected items
261261
// setTimeout just defers the call to the next check cycle
262262
setTimeout(() => {
@@ -286,12 +286,15 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
286286
hostkeys(ev: KeyboardEvent) {
287287
if (ev.key === "Escape") {
288288
this.closeDropdown();
289-
} else if (ev.key === "ArrowDown" && !this.dropdownMenu.nativeElement.contains(ev.target)) {
289+
} else if ((ev.key === "ArrowDown" || ev.key === "Down") // `"Down"` is IE specific value
290+
&& (!this.dropdownMenu || !this.dropdownMenu.nativeElement.contains(ev.target))) {
290291
ev.stopPropagation();
291292
this.openDropdown();
292293
setTimeout(() => this.view.getCurrentElement().focus(), 0);
293-
} else if (ev.key === "ArrowUp" && this.dropdownMenu.nativeElement.contains(ev.target) && !this.view["hasPrevElement"]()) {
294-
this.elementRef.nativeElement.querySelector(".combobox_input").focus();
294+
} else if ((ev.key === "ArrowUp" || ev.key === "Up") // `"Up"` is IE specific value
295+
&& this.dropdownMenu.nativeElement.contains(ev.target)
296+
&& !this.view.hasPrevElement()) {
297+
this.elementRef.nativeElement.querySelector(".bx--text-input").focus();
295298
}
296299
}
297300

@@ -340,7 +343,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
340343
}
341344
return item;
342345
});
343-
this.view["updateList"](this.items);
346+
this.view.items = this.items;
344347
this.updatePills();
345348
// clearSelected can only fire on type=multi
346349
// so we just emit getSelected() (just in case there's any disabled but selected items)
@@ -349,7 +352,6 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
349352

350353
/**
351354
* Closes the dropdown and emits the close event.
352-
* @memberof ComboBox
353355
*/
354356
public closeDropdown() {
355357
this.open = false;
@@ -358,15 +360,13 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
358360

359361
/**
360362
* Opens the dropdown.
361-
* @memberof ComboBox
362363
*/
363364
public openDropdown() {
364365
this.open = true;
365366
}
366367

367368
/**
368369
* Toggles the dropdown.
369-
* @memberof ComboBox
370370
*/
371371
public toggleDropdown() {
372372
if (this.open) {
@@ -381,7 +381,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
381381
* @param {string} searchString
382382
*/
383383
public onSearch(searchString) {
384-
this.view["filterBy"](searchString);
384+
this.view.filterBy(searchString);
385385
if (searchString !== "") {
386386
this.openDropdown();
387387
} else {
@@ -390,7 +390,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
390390
if (this.type === "single") {
391391
// deselect if the input doesn't match the content
392392
// of any given item
393-
const matches = this.view.items.some(item => item.content.toLowerCase().includes(searchString.toLowerCase()));
393+
const matches = this.view.getListItems().some(item => item.content.toLowerCase().includes(searchString.toLowerCase()));
394394
if (!matches) {
395395
const selected = this.view.getSelected();
396396
if (selected) {
@@ -399,7 +399,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
399399
this.view.select.emit({ item: selected[0] });
400400
this.propagateChangeCallback(null);
401401
} else {
402-
this.view["filterBy"]("");
402+
this.view.filterBy("");
403403
}
404404
}
405405
}
@@ -421,10 +421,10 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
421421
public onSubmit(ev) {
422422
let index = 0;
423423
if (ev.after) {
424-
index = this.view.items.indexOf(ev.after) + 1;
424+
index = this.view.getListItems().indexOf(ev.after) + 1;
425425
}
426426
this.submit.emit({
427-
items: this.view.items,
427+
items: this.view.getListItems(),
428428
index,
429429
value: {
430430
content: ev.value,

0 commit comments

Comments
 (0)