OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Use trackBy and compareWith to ensure we're matching the same selection
Oliver Günther967055d92895
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.html b/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.htmlindex 00bc14d17db..d9c89f6939d 100644--- a/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.html+++ b/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.html@@ -16,6 +16,8 @@[focusDirectly]="shouldFocus"[model]="value"[resource]="resourceType"+ [compareWith]="compareByHref"+ [trackByFn]="itemTracker"(change)="setValues($event)"></op-autocompleter></div>diff --git a/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts b/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.tsindex d19b9611696..bdb5ad70c3d 100644--- a/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts+++ b/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts@@ -34,6 +34,7 @@ import { I18nService } from 'core-app/core/i18n/i18n.service';import { CurrentUserService } from 'core-app/core/current-user/current-user.service';import { take } from 'rxjs/internal/operators/take';import { CollectionResource } from 'core-app/features/hal/resources/collection-resource';+import { compareByHref } from 'core-app/shared/helpers/angular/tracking-functions';@Component({selector: 'op-filter-searchable-multiselect-value',@@ -62,6 +63,10 @@ export class FilterSearchableMultiselectValueComponent extends UntilDestroyedMixinitialRequest$:Observable<CollectionResource>;+ itemTracker = (item:HalResource):string => item.href || item.id || item.name;++ compareByHref = compareByHref;+resourceType:string|null = null;readonly text = {diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.htmlindex 8ca7a9a70d5..ddbc2eff82d 100644--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html@@ -41,6 +41,7 @@[searchable]="searchable"[selectableGroupAsModel]="selectableGroupAsModel"[trackByFn]="trackByFn"+ [compareWith]="compareWith"[searchFn]="searchFn"[labelForId]="labelForId"[inputAttrs]="inputAttrs"diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.tsindex 170337183ef..d97d1df6626 100644--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts@@ -42,7 +42,6 @@ import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { Highlighting } from 'core-app/features/work-packages/components/wp-fast-table/builders/highlighting/highlighting.functions';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { compareByHrefOrString } from 'core-app/shared/helpers/angular/tracking-functions';import { OpAutocompleterFooterTemplateDirective } from 'core-app/shared/components/autocompleter/autocompleter-footer-template/op-autocompleter-footer-template.directive';import { OpAutocompleterService } from './services/op-autocompleter.service';@@ -158,6 +157,8 @@ export class OpAutocompleterComponent extends UntilDestroyedMixin implements OnI@Input() public trackByFn ? = null;+ @Input() public compareWith ? = (a:unknown, b:unknown):boolean => a === b;+@Input() public clearOnBackspace?:boolean = true;@Input() public labelForId ? = null;@@ -205,8 +206,6 @@ export class OpAutocompleterComponent extends UntilDestroyedMixin implements OnI@Output() public scrollToEnd = new EventEmitter();- public compareByHrefOrString = compareByHrefOrString;-public active:Set<string>;public results$:Observable<unknown>;diff --git a/spec/features/work_packages/table/queries/filter_spec.rb b/spec/features/work_packages/table/queries/filter_spec.rbindex e194bdb89be..add96751a11 100644--- a/spec/features/work_packages/table/queries/filter_spec.rb+++ b/spec/features/work_packages/table/queries/filter_spec.rb@@ -118,6 +118,39 @@ describe 'filter work packages', js: true doendend+ context 'when filtering by status in project' do+ let(:status) { create :status, name: 'Open status' }+ let(:closed_status) { create :closed_status, name: 'Closed status' }+ let(:work_package_with_status) do+ create :work_package, project:, subject: 'With open status', status:+ end+ let(:work_package_without_status) { create :work_package, subject: 'With closed status', project:, status: closed_status }++ before do+ work_package_with_status+ work_package_without_status++ wp_table.visit!+ end++ it 'allows filtering and matching the selected value' do+ filters.open++ filters.remove_filter :status+ filters.expect_no_filter_by :status+ filters.add_filter_by('Status', 'is', status.name)++ loading_indicator_saveguard+ wp_table.expect_work_package_listed work_package_with_status+ wp_table.ensure_work_package_not_listed! work_package_without_status++ filters.open_autocompleter :status++ expect(page).to have_selector('.ng-option', text: closed_status.name)+ expect(page).to have_no_selector('.ng-option', text: status.name)+ end+ end+context 'by finish date outside of a project' dolet(:work_package_with_due_date) { create :work_package, project:, due_date: Date.today }let(:work_package_without_due_date) { create :work_package, project:, due_date: Date.today + 5.days }diff --git a/spec/support/components/work_packages/filters.rb b/spec/support/components/work_packages/filters.rbindex 1056ff602d5..e5afb10835e 100644--- a/spec/support/components/work_packages/filters.rb+++ b/spec/support/components/work_packages/filters.rb@@ -162,6 +162,20 @@ module Componentsfind("#filter_#{field} .advanced-filters--remove-filter-icon").clickend+ def open_autocompleter(id)+ input = page.all("#filter_#{id} .advanced-filters--filter-value .ng-input input").first++ if input+ input.click+ input+ end+ end++ def close_autocompleter(id)+ input = open_autocompleter(id)+ input&.send_keys :escape+ end+protecteddef filter_button@@ -233,15 +247,6 @@ module Componentsyield page.has_selector?('.ng-select-container')endend-- def close_autocompleter(id)- input = page.all("#filter_#{id} .advanced-filters--filter-value .ng-input input").first-- if input- input.click- input.send_keys :escape- end- endendendend