Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert: Handling label reactively for dropdown item #492

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/komponentkartan/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vgr-komponentkartan",
"version": "7.8.1",
"version": "7.8.3",
"peerDependencies": {
"@angular/common": "^9.1.7",
"@angular/core": "^9.1.7",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Component, Input, EventEmitter, Output, ViewChild, ElementRef } from '@angular/core';
import { Component, Input, EventEmitter, Output, ViewChild, ElementRef, AfterViewInit } from '@angular/core';

@Component({
selector: 'vgr-dropdown-item',
templateUrl: './dropdown-item.component.html'
})
export class DropdownItemComponent {
export class DropdownItemComponent implements AfterViewInit {

@Input() selectedLabel: string;
@Input() value: any;
Expand All @@ -14,16 +14,19 @@ export class DropdownItemComponent {
@Output() next = new EventEmitter();
@Output() nextMatch = new EventEmitter<string>();
@ViewChild('item') item: ElementRef;

get label(): any {
return this.value;
}

label: string;
multi = false;
selected = false;
visible = true;
hasFocus = false;

ngAfterViewInit() {
this.label = (this.item.nativeElement as Node).textContent.trim();
if (this.value === undefined) {
this.value = this.label;
}
}

toggleSelect() {
if (this.multi) {
this.selected = !this.selected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class DropdownSelectComponent implements OnChanges, AfterContentInit, Aft

if (this.items) {
this.items.forEach(item => {
item.visible = item.label.toString().toLowerCase().includes(value.toLowerCase());
item.visible = item.label.toLowerCase().includes(value.toLowerCase());
});
this.visibleCount = this.items.filter(e => e.visible).length;
this.updateAllCheckedStatus();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import {
Component, AfterViewChecked, QueryList, forwardRef, ElementRef, ContentChildren, Renderer2, OnDestroy, Output, EventEmitter
} from '@angular/core';
Expand Down