Fix keep-scroll-position for reload banner

This commit is contained in:
Mir Bhatia
2026-04-15 11:30:39 +02:00
parent 63bef28314
commit 8d0dcd6056
6 changed files with 16 additions and 15 deletions
+2 -1
View File
@@ -285,7 +285,8 @@ module ApplicationHelper
def body_data_attributes(local_assigns)
{
controller: "application auto-theme-switcher hover-card-trigger beforeunload external-links highlight-target-element",
controller: ["application auto-theme-switcher hover-card-trigger beforeunload external-links highlight-target-element",
stimulus_body_controller].compact.join(" "),
relative_url_root: root_path,
overflowing_identifier: ".__overflowing_body",
external_links_enabled_value: Setting.capture_external_links?,
+8
View File
@@ -39,5 +39,13 @@ module StimulusHelper
@stimulus_content_data || {}
end
def body_controller(name)
@stimulus_body_controller = name
end
def stimulus_body_controller
@stimulus_body_controller
end
# rubocop:enable Rails/HelperInstanceVariable
end
@@ -31,16 +31,10 @@
import { ApplicationController } from 'stimulus-use';
export default class KeepScrollPositionController extends ApplicationController {
static values = {
url: String,
};
static targets = ['triggerButton'];
declare triggerButtonTarget:HTMLLinkElement;
declare urlValue:string;
connect() {
super.connect();
@@ -80,6 +74,6 @@ export default class KeepScrollPositionController extends ApplicationController
}
private scrollPositionKey():string {
return `${this.urlValue}/scrollPosition`;
return `${window.location.pathname}/scrollPosition`;
}
}
@@ -1,8 +1,8 @@
<%=
helpers.content_controller "poll-for-changes keep-scroll-position",
helpers.content_controller "poll-for-changes",
poll_for_changes_url_value: check_for_updates_project_meeting_path(@meeting.project, @meeting),
poll_for_changes_interval_value: check_for_updates_interval,
keep_scroll_position_url_value: meeting_path(@meeting)
poll_for_changes_interval_value: check_for_updates_interval
helpers.body_controller "keep-scroll-position"
component_wrapper do
render(
@@ -1,5 +1,4 @@
<% helpers.content_controller "keep-scroll-position",
keep_scroll_position_url_value: polymorphic_path([@project, :meetings]) %>
<% helpers.content_controller "keep-scroll-position" %>
<%= render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { page_title }
@@ -1,6 +1,5 @@
<%=
helpers.content_controller "keep-scroll-position",
keep_scroll_position_url_value: polymorphic_path([@project, @meeting])
helpers.content_controller "keep-scroll-position"
component_wrapper do
render(Primer::OpenProject::PageHeader.new) do |header|