();
private _highlightText: string;
private _propertiesToSearch: string[];
private _search: SkyAutocompleteSearchFunction;
@@ -178,6 +188,12 @@ export class SkyAutocompleteComponent
.subscribe(() => {
this.isMouseEnter = false;
});
+
+ this.messageStream
+ .takeUntil(this.ngUnsubscribe)
+ .subscribe((message: SkyDropdownMessage) => {
+ this.handleIncomingMessages(message);
+ });
}
public ngAfterContentInit(): void {
@@ -224,17 +240,21 @@ export class SkyAutocompleteComponent
}
if (change.items) {
- this.sendDropdownMessage(SkyDropdownMessageType.FocusFirstItem);
+ this.sendMessage(SkyDropdownMessageType.FocusFirstItem);
}
}
+ public onPopoverOpened() {
+ this.sendMessage(SkyDropdownMessageType.Open);
+ }
+
private handleKeyDown(event: KeyboardEvent): void {
const key = event.key.toLowerCase();
/* tslint:disable-next-line:switch-default */
switch (key) {
case 'arrowup':
- this.sendDropdownMessage(SkyDropdownMessageType.FocusPreviousItem);
+ this.sendMessage(SkyDropdownMessageType.FocusPreviousItem);
event.preventDefault();
break;
@@ -246,7 +266,7 @@ export class SkyAutocompleteComponent
this.searchTextChanged(text);
event.preventDefault();
} else {
- this.sendDropdownMessage(SkyDropdownMessageType.FocusNextItem);
+ this.sendMessage(SkyDropdownMessageType.FocusNextItem);
event.preventDefault();
}
break;
@@ -285,7 +305,7 @@ export class SkyAutocompleteComponent
if (isLongEnough && isDifferent) {
this.performSearch().then((results: any[]) => {
if (!this.hasSearchResults()) {
- this.sendDropdownMessage(SkyDropdownMessageType.Open);
+ this.positionPopover();
}
this._searchResults = results;
@@ -317,15 +337,48 @@ export class SkyAutocompleteComponent
this.closeDropdown();
}
+ private handleIncomingMessages(message: SkyDropdownMessage) {
+ /* tslint:disable-next-line:switch-default */
+ switch (message.type) {
+ case SkyDropdownMessageType.Open:
+ this.dropdownMenu.focusFirstItem();
+ break;
+
+ case SkyDropdownMessageType.FocusNextItem:
+ this.dropdownMenu.focusNextItem();
+ break;
+
+ case SkyDropdownMessageType.FocusPreviousItem:
+ this.dropdownMenu.focusPreviousItem();
+ break;
+
+ case SkyDropdownMessageType.Close:
+ this.popover.close();
+ break;
+
+ case SkyDropdownMessageType.FocusTriggerButton:
+ this.inputDirective.elementRef.nativeElement.focus();
+ break;
+ }
+ }
+
+ private positionPopover() {
+ this.popover.positionNextTo(
+ this.elementRef,
+ 'below',
+ this.alignment
+ );
+ }
+
private closeDropdown(): void {
this._searchResults = [];
this._highlightText = '';
this.changeDetector.markForCheck();
- this.sendDropdownMessage(SkyDropdownMessageType.Close);
+ this.sendMessage(SkyDropdownMessageType.Close);
}
- private sendDropdownMessage(type: SkyDropdownMessageType): void {
- this.dropdownController.next({ type });
+ private sendMessage(type: SkyDropdownMessageType): void {
+ this.messageStream.next({ type });
}
private hasSearchResults(): boolean {
diff --git a/src/modules/autocomplete/autocomplete.module.ts b/src/modules/autocomplete/autocomplete.module.ts
index 15b2682c7..6c5c9ded2 100644
--- a/src/modules/autocomplete/autocomplete.module.ts
+++ b/src/modules/autocomplete/autocomplete.module.ts
@@ -7,6 +7,7 @@ import { SkyTextHighlightModule } from '../text-highlight';
import { SkyAutocompleteComponent } from './autocomplete.component';
import { SkyAutocompleteInputDirective } from './autocomplete-input.directive';
+import { SkyPopoverModule } from '../popover';
@NgModule({
declarations: [
@@ -17,7 +18,8 @@ import { SkyAutocompleteInputDirective } from './autocomplete-input.directive';
CommonModule,
FormsModule,
SkyTextHighlightModule,
- SkyDropdownModule
+ SkyDropdownModule,
+ SkyPopoverModule
],
exports: [
SkyAutocompleteComponent,
diff --git a/src/modules/colorpicker/colorpicker.component.html b/src/modules/colorpicker/colorpicker.component.html
index e6a545e51..eb1394c62 100644
--- a/src/modules/colorpicker/colorpicker.component.html
+++ b/src/modules/colorpicker/colorpicker.component.html
@@ -1,9 +1,7 @@
-
-
+ -->
+
+
+
+