From 0a53c62287df203c3c0e34631bdeeb34000e0f83 Mon Sep 17 00:00:00 2001 From: Ko Nagase Date: Tue, 14 May 2024 13:38:20 +0900 Subject: [PATCH] Fix switching gtt disabled/enabled projects issues map rendering --- app/helpers/gtt_map_helper.rb | 7 +++++++ test/system/issues_map_test.rb | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/helpers/gtt_map_helper.rb b/app/helpers/gtt_map_helper.rb index caca1044..c3741af3 100644 --- a/app/helpers/gtt_map_helper.rb +++ b/app/helpers/gtt_map_helper.rb @@ -68,6 +68,13 @@ def map_tag(map: nil, layers: map&.layers, window.createGttClient(target); contentObserver(); }, { once: true }); + var target = document.getElementById('#{uid}'); + if ( + document.readyState === 'complete' + && !target.hasChildNodes() + ) { + window.createGttClient(target); + } } document.addEventListener('DOMContentLoaded', function(){ var target = document.getElementById('#{uid}'); diff --git a/test/system/issues_map_test.rb b/test/system/issues_map_test.rb index 6b2b9ced..eb8dd8f9 100644 --- a/test/system/issues_map_test.rb +++ b/test/system/issues_map_test.rb @@ -57,10 +57,8 @@ class IssuesMapTest < ApplicationSystemTestCase # Select gtt enabled project again page.find('#issue_project_id').select('eCookbook') - ## FIXME: Should replace to commented out assertions below - assert_selector('div.ol-map') - # assert_selector('div.ol-map') do - # assert_selector('canvas') - # end + assert_selector('div.ol-map') do + assert_selector('canvas') + end end end