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

Bug/58462 orphaned connection line when filtering activity for comments only (#17121)

jjabari-opcaadd1ee42ec
diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.html.erb b/app/components/work_packages/activities_tab/journals/item_component/details.html.erb
index 04e3144a0aa..f8b19b5d407 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/details.html.erb
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.html.erb
@@ -1,6 +1,11 @@
<%=
component_wrapper(class: "work-packages-activities-tab-journals-item-component-details") do
- flex_layout(my: 0, border: :left, classes: "work-packages-activities-tab-journals-item-component-details--journal-details-container") do |details_container|
+ flex_layout(
+ my: 0,
+ border: :left,
+ classes: "work-packages-activities-tab-journals-item-component-details--journal-details-container",
+ data: { initial: journal.initial? }
+ ) do |details_container|
case filter
when :only_comments
render_empty_line(details_container) unless journal.notes.blank? && !journal.noop?
diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.sass b/app/components/work_packages/activities_tab/journals/item_component/details.sass
index 26c4b535a6a..9aaa0e6ca65 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/details.sass
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.sass
@@ -2,6 +2,11 @@
&--journal-details-container
margin-left: 19px
min-height: 20px
+ // applied by the stimulus controller in specific UI states
+ &--border-removed
+ border-left: none!important
+ &--hidden
+ display: none!important
&--journal-details-container--empty--last--asc
display: none!important
&--journal-details-header-container
diff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rb
index 5d2d8e6c73e..98d7c3ef6b7 100644
--- a/app/controllers/work_packages/activities_tab_controller.rb
+++ b/app/controllers/work_packages/activities_tab_controller.rb
@@ -58,18 +58,9 @@ class WorkPackages::ActivitiesTabController < ApplicationController
end
def update_filter
- update_via_turbo_stream(
- component: WorkPackages::ActivitiesTab::Journals::FilterAndSortingComponent.new(
- work_package: @work_package,
- filter: @filter
- )
- )
- update_via_turbo_stream(
- component: WorkPackages::ActivitiesTab::Journals::IndexComponent.new(
- work_package: @work_package,
- filter: @filter
- )
- )
+ # update the whole tab to reflect the new filtering in all components
+ # we need to call replace in order to properly re-init the index stimulus component
+ replace_whole_tab
respond_with_turbo_streams
end
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
index 8393c8eec32..955d44d3d96 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
@@ -62,6 +62,7 @@ export default class IndexController extends Controller {
this.turboRequests = context.services.turboRequests;
this.apiV3Service = context.services.apiV3Service;
+ this.handleStemVisibility();
this.setLocalStorageKey();
this.setupEventListeners();
this.handleInitialScroll();
@@ -196,13 +197,14 @@ export default class IndexController extends Controller {
});
}
- private handleUpdateStreamsResponse(html:string, lastResponseHeaders:Headers, journalsContainerAtBottom:boolean) {
- // extract server timestamp from response headers in order to be in sync with the server
- this.setLastServerTimestampViaHeaders(lastResponseHeaders);
-
- this.checkForAndHandleWorkPackageUpdate(html);
- this.checkForNewNotifications(html);
- this.performAutoScrolling(html, journalsContainerAtBottom);
+ private handleUpdateStreamsResponse(html:string, headers:Headers, journalsContainerAtBottom:boolean) {
+ setTimeout(() => {
+ this.handleStemVisibility();
+ this.setLastServerTimestampViaHeaders(headers);
+ this.checkForAndHandleWorkPackageUpdate(html);
+ this.checkForNewNotifications(html);
+ this.performAutoScrolling(html, journalsContainerAtBottom);
+ }, 100);
}
private checkForAndHandleWorkPackageUpdate(html:string) {
@@ -573,6 +575,7 @@ export default class IndexController extends Controller {
true,
);
}
+ this.handleStemVisibility();
}, 10);
this.saveInProgress = false;
@@ -598,4 +601,44 @@ export default class IndexController extends Controller {
this.lastServerTimestampValue = headers.get('X-Server-Timestamp') as string;
}
}
+
+ // Towards the code below:
+ // Ideally the stem rendering would be correctly rendered for all UI states from the server
+ // but as we push single elements into the DOM via turbo-streams, the server-side rendered collection state gets stale quickly
+ // I've decided to go with a client-side rendering-correction approach for now
+ // as I don't want to introduce more complexity and queries (n+1 for position checks etc.) to the server-side rendering
+ private handleStemVisibility() {
+ this.handleStemVisibilityForMobile();
+ this.handleLastStemPartVisibility();
+ }
+
+ private handleStemVisibilityForMobile() {
+ if (this.isMobile()) {
+ if (this.sortingValue === 'asc') return;
+
+ const initialJournalContainer = this.element.querySelector('.work-packages-activities-tab-journals-item-component-details--journal-details-container[data-initial="true"]') as HTMLElement;
+
+ if (initialJournalContainer) {
+ initialJournalContainer.classList.add('work-packages-activities-tab-journals-item-component-details--journal-details-container--border-removed');
+ }
+ }
+ }
+
+ private handleLastStemPartVisibility() {
+ const emptyLines = this.element.querySelectorAll('.empty-line');
+
+ // make sure all are visible first
+ emptyLines.forEach((container) => {
+ container.classList.remove('work-packages-activities-tab-journals-item-component-details--journal-details-container--hidden');
+ });
+
+ if (this.sortingValue === 'asc' || this.filterValue === 'only_changes') return;
+
+ // then hide the last one again
+ if (emptyLines.length > 0) {
+ // take the parent container of the last empty line
+ const lastEmptyLineContainer = emptyLines[emptyLines.length - 1].parentElement as HTMLElement;
+ lastEmptyLineContainer.classList.add('work-packages-activities-tab-journals-item-component-details--journal-details-container--hidden');
+ }
+ }
}