Skip to content

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

[58704] Quick wins for top bar search (#18800)

Behrokh Satarnejad5b8b102db2e8
diff --git a/frontend/src/app/core/global_search/input/global-search-input-mobile.component.sass b/frontend/src/app/core/global_search/input/global-search-input-mobile.component.sass
index 70825c6fbc5..c73a9265ee6 100644
--- a/frontend/src/app/core/global_search/input/global-search-input-mobile.component.sass
+++ b/frontend/src/app/core/global_search/input/global-search-input-mobile.component.sass
@@ -2,7 +2,7 @@
$search-input-height-mobile: 36px
-@media screen and (max-width: $breakpoint-sm)
+@media screen and (max-width: $breakpoint-md)
.top-menu-search
&--input
display: none
@@ -32,6 +32,9 @@ $search-input-height-mobile: 36px
.ng-input input
height: 36px
+ .ng-dropdown-panel
+ width: 100% !important
+
.top-menu-search--back-button
@include unset-button-styles
display: initial
diff --git a/frontend/src/app/core/global_search/input/global-search-input.component.html b/frontend/src/app/core/global_search/input/global-search-input.component.html
index f91c0674956..f58b092f78d 100644
--- a/frontend/src/app/core/global_search/input/global-search-input.component.html
+++ b/frontend/src/app/core/global_search/input/global-search-input.component.html
@@ -17,8 +17,9 @@
[accesskey]="4"
class="global-search"
[placeholder]="placeholder"
+ [dropdownPosition]="'bottom'"
[classes]="{'top-menu-search--input': true, '-markable': markable, '-expanded': expanded }"
- [inputAttrs]="{ 'class': 'global-search--input', 'name': 'global-search--input' }"
+ [inputAttrs]="{ 'class': 'global-search--input', 'name': 'global-search--input', autocomplete: 'off'}"
[openOnEnter]="true"
[labelRequired]="false"
[focusDirectly]="isFocusedDirectly"
@@ -44,8 +45,8 @@
<ng-template op-autocompleter-option-tmp let-item let-index="index" let-search="searchTerm">
<div *ngIf="!item.id; else workPackageItemTemplate">
<div tabindex="-1" class="global-search--option" (click)="followItem(item)">
- <div class="global-search--search-term"> {{currentValue}}</div>
- <div class="global-search--project-scope" title="{{item.projectScope}}">{{item.text}} ↵</div>
+ <div class="global-search--search-term">{{ currentValue }}</div>
+ <div class="global-search--project-scope" title="{{ item.projectScope }}">{{ item.text }} ↵</div>
</div>
</div>
<ng-template #workPackageItemTemplate>
@@ -56,30 +57,28 @@
(click)="redirectToWp(item.id, $event)"
style="line-height: 1"
>
- <op-principal
- [hideName]="true"
- [principal]="item.author"
- [hoverCard]="true"
- class="hidden-for-mobile global-search--principal"
- ></op-principal>
<div class="global-search--option-meta">
- <span class="global-search--wp-subject">
+ <div class="global-search--wp-line">
+ <span [ngClass]="highlighting('type', item.type.id)">
+ {{ item.type.name }}
+ </span>
+ <span>#{{ item.id }}</span>
+ <span [ngClass]="statusHighlighting(item.status.id)">
+ {{ item.status.name }}
+ </span>
+ <span>-</span>
<span
- [ngClass]="highlighting('type', item.type.id)"
- [textContent]="item.type.name"
- ></span>
- {{item.subject}}
- </span>
-
- <div class="global-search--wp-content">
- <span [textContent]="item.project.name" class="global-search--wp-project"></span>
- #{{item.id}}
- <span
- [textContent]="item.status.name"
- [ngClass]="statusHighlighting(item.status.id)"
- class="global-search--wp-status"
- ></span>
+ class="global-search--wp-project"
+ [attr.title]="item.project.name"
+ >
+ {{ item.project.name }}
+ </span>
</div>
+ <span
+ class="global-search--wp-subject"
+ >
+ {{ item.subject }}
+ </span>
</div>
</a>
</ng-template>
diff --git a/frontend/src/app/core/global_search/input/global-search-input.component.sass b/frontend/src/app/core/global_search/input/global-search-input.component.sass
index d3bb6d02f90..9691002e003 100644
--- a/frontend/src/app/core/global_search/input/global-search-input.component.sass
+++ b/frontend/src/app/core/global_search/input/global-search-input.component.sass
@@ -108,6 +108,9 @@ $search-input-height: 30px
max-height: 80vh
height: auto
+ .ng-dropdown-panel
+ width: 500px !important
+
.ng-option
border-bottom: 1px solid var(--borderColor-default)
white-space: normal
diff --git a/frontend/src/app/core/global_search/input/global-search-input.component.ts b/frontend/src/app/core/global_search/input/global-search-input.component.ts
index b20564aad84..c9b778c90fd 100644
--- a/frontend/src/app/core/global_search/input/global-search-input.component.ts
+++ b/frontend/src/app/core/global_search/input/global-search-input.component.ts
@@ -357,7 +357,7 @@ export class GlobalSearchInputComponent implements AfterViewInit, OnDestroy {
return this
.apiV3Service
.work_packages
- .filterByTypeaheadOrId(query, idOnly);
+ .filterByTypeaheadOrId(query, idOnly, { pageSize: '20' });
}
private searchResultsToOptions(results:WorkPackageResource[], query:string) {
diff --git a/frontend/src/app/core/global_search/input/global-search.component.sass b/frontend/src/app/core/global_search/input/global-search.component.sass
index 56d53a00cc5..3076812a43b 100644
--- a/frontend/src/app/core/global_search/input/global-search.component.sass
+++ b/frontend/src/app/core/global_search/input/global-search.component.sass
@@ -33,7 +33,7 @@
flex-grow: 0
flex-shrink: 1
border: 1px solid var(--button-default-borderColor-rest)
- font-size: 13px
+ font-size: var(--text-body-size-small)
background: var(--button--background-color)
border-radius: 2px
padding: 0 4px
@@ -45,33 +45,40 @@
margin-left: -5px
&--wp-content
- display: grid
- grid-template-columns: 50% 1fr auto
- grid-template-areas: "project idlink status"
+ display: flex
+ flex-direction: column
font-size: 0.8rem
- padding: 5px 0 5px 0px
+ padding: 5px 0
+
+ &--wp-line
+ display: flex
+ flex-wrap: nowrap
+ gap: var(--base-size-8)
+ font-size: var(--text-body-size-small)
+ white-space: nowrap
+ overflow: hidden
+ margin-bottom: var(--base-size-4)
&--wp-project
- grid-area: project
+ flex-shrink: 1
+ min-width: 0
+ max-width: 100%
@include text-shortener
&--wp-id
- grid-area: idlink
place-self: right
font-style: italic
color: var(--fgColor-muted)
- font-size: 13px
+ font-size: var(--text-body-size-small)
white-space: nowrap
&--wp-status
- grid-area: status
overflow: hidden
font-style: italic
&--wp-subject
font-weight: var(--base-text-weight-bold)
display: inline-block
- overflow: hidden
- white-space: nowrap
- text-overflow: ellipsis
+ white-space: normal
+ overflow-wrap: break-word
line-height: 1.5
diff --git a/spec/features/search/search_spec.rb b/spec/features/search/search_spec.rb
index 25d6fa581fd..cfe8cb32f23 100644
--- a/spec/features/search/search_spec.rb
+++ b/spec/features/search/search_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe "Search", :js, :selenium, with_settings: { per_page_options: "5"
shared_let(:admin) { create(:admin) }
shared_let(:project) { create(:project) }
shared_let(:work_packages) do
- (1..12).map do |n|
+ (1..22).map do |n|
Timecop.freeze("2016-11-21 #{n}:00".to_datetime) do
subject = "Subject No. #{n} WP"
create(:work_package,
@@ -108,7 +108,7 @@ RSpec.describe "Search", :js, :selenium, with_settings: { per_page_options: "5"
global_search.search(query, submit: false)
# Suggestions shall show latest WPs first.
- global_search.expect_work_package_option(work_packages[11])
+ global_search.expect_work_package_option(work_packages[21])
# and show maximum 10 suggestions.
global_search.expect_work_package_option(work_packages[2])
global_search.expect_no_work_package_option(work_packages[1])
@@ -311,8 +311,8 @@ RSpec.describe "Search", :js, :selenium, with_settings: { per_page_options: "5"
table = Pages::EmbeddedWorkPackagesTable.new(find(".work-packages-embedded-view--container"))
table.expect_work_package_count(5) # because we set the page size to this
# Expect order to be from newest to oldest.
- table.expect_work_package_listed(*work_packages[7..12]) # This line ensures that the table is completely rendered.
- table.expect_work_package_order(*work_packages[7..12].map { |wp| wp.id.to_s }.reverse)
+ table.expect_work_package_listed(*work_packages[17..22]) # This line ensures that the table is completely rendered.
+ table.expect_work_package_order(*work_packages[17..22].map { |wp| wp.id.to_s }.reverse)
# Expect that "Advanced filters" can refine the search:
filters.expect_closed
@@ -565,14 +565,14 @@ RSpec.describe "Search", :js, :selenium, with_settings: { per_page_options: "5"
describe "pagination" do
context "for project wide search" do
it "works" do
- expect_range 3, 12
+ expect_range 13, 22
click_on "Next", match: :first
- expect_range 1, 2
+ expect_range 11, 12
expect(page).to have_current_path /\/projects\/#{project.identifier}\/search/
click_on "Previous", match: :first
- expect_range 3, 12
+ expect_range 13, 22
expect(page).to have_current_path /\/projects\/#{project.identifier}\/search/
end
end
@@ -585,13 +585,13 @@ RSpec.describe "Search", :js, :selenium, with_settings: { per_page_options: "5"
end
it "works" do
- expect_range 3, 12
+ expect_range 13, 22
click_on "Next", match: :first
- expect_range 1, 2
+ expect_range 11, 12
click_on "Previous", match: :first
- expect_range 3, 12
+ expect_range 13, 22
end
end
end