From c91aba58e58972e41d9f2bb364d882b96b2e8e72 Mon Sep 17 00:00:00 2001 From: Katsuya HIDAKA Date: Wed, 14 Oct 2026 23:13:30 +0900 Subject: Remove unnecessary Gantt redraws on window resize --- app/helpers/gantt_helper.rb | 2 +- .../controllers/gantt/chart_controller.js | 1 - test/system/gantts_test.rb | 20 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/helpers/gantt_helper.rb b/app/helpers/gantt_helper.rb index dfd3a2475..5ea0b7c54 100644 --- a/app/helpers/gantt_helper.rb +++ b/app/helpers/gantt_helper.rb @@ -222,7 +222,7 @@ module GanttHelper # - `gantt--options` toggles checkboxes under Options. # - `gantt--subjects` reports tree expand/collapse. # - Mouse events synchronize the hovered row across the chart panes. - # - Window resize triggers a redraw of progress lines and relations. + # - Window resize updates selected column visibility for mobile layouts. action: %w( gantt--options:toggle-display@document->gantt--chart#handleOptionsDisplay gantt--options:toggle-relations@document->gantt--chart#handleOptionsRelations diff --git a/app/javascript/controllers/gantt/chart_controller.js b/app/javascript/controllers/gantt/chart_controller.js index 96f3e851a..6244cd496 100644 --- a/app/javascript/controllers/gantt/chart_controller.js +++ b/app/javascript/controllers/gantt/chart_controller.js @@ -87,7 +87,6 @@ export default class extends Controller { handleWindowResize() { this.handleChartResize() - this.#drawProgressLineAndRelations() this.#drawSelectedColumns() } diff --git a/test/system/gantts_test.rb b/test/system/gantts_test.rb index 3fa836786..ab913ef7f 100644 --- a/test/system/gantts_test.rb +++ b/test/system/gantts_test.rb @@ -179,6 +179,26 @@ class GanttsTest < ApplicationSystemTestCase assert_equal expected_width, column_width('subjects') end + test 'window resizing preserves line positions and updates selected columns' do + visit_gantt + expand_options + find('#draw_selected_columns').check + find('#draw_progress_line').check + + assert_selector '.gantt-relations path', minimum: 1 + line_positions = -> { page.evaluate_script("Array.from(document.querySelectorAll('.gantt-relations path'), path => path.getAttribute('d'))") } + positions_before_resize = line_positions.call + + [[899, :hidden], [900, :visible]].each do |width, visibility| + page.current_window.resize_to(width, 900) + + assert_selector '.gantt-selected-column', visible: visibility + assert_equal positions_before_resize, line_positions.call + end + ensure + page.current_window.resize_to(1024, 900) + end + test 'context menu and tooltip interactions' do visit_gantt -- 2.51.0