From 5c8e43a31cdf9326e37eb0c475106bb347c87c39 Mon Sep 17 00:00:00 2001 From: Faye-yufan Date: Sat, 3 Jun 2023 22:27:37 +0800 Subject: [PATCH 1/3] Fix Scrollbar Jumping Issue in Firefox --- inst/htmljs/animint.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 01dd1e740..43bf034b4 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2392,6 +2392,11 @@ var animint = function (to_select, json_file) { .attr("class", "table_selector_widgets") ; var selector_first_tr = selector_table.append("tr"); + setTimeout(() => { + const selector_height = selector_table[0][0].clientHeight; + selector_table + .style('height', `${selector_height}px`); + }, 0); selector_first_tr .append("th") .text("Variable") From ac95de2d4b1faa72d21b4034a9fe1ea9f2e635e9 Mon Sep 17 00:00:00 2001 From: Faye-yufan Date: Tue, 25 Jul 2023 08:22:00 -0700 Subject: [PATCH 2/3] created a test case and comment out the fix (for testing) --- inst/htmljs/animint.js | 10 +++++----- tests/testthat/test-renderer5-firefox.R | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 tests/testthat/test-renderer5-firefox.R diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 43bf034b4..a31ca49de 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2392,11 +2392,11 @@ var animint = function (to_select, json_file) { .attr("class", "table_selector_widgets") ; var selector_first_tr = selector_table.append("tr"); - setTimeout(() => { - const selector_height = selector_table[0][0].clientHeight; - selector_table - .style('height', `${selector_height}px`); - }, 0); + // setTimeout(() => { + // const selector_height = selector_table[0][0].clientHeight; + // selector_table + // .style('height', `${selector_height}px`); + // }, 0); selector_first_tr .append("th") .text("Variable") diff --git a/tests/testthat/test-renderer5-firefox.R b/tests/testthat/test-renderer5-firefox.R new file mode 100644 index 000000000..774184242 --- /dev/null +++ b/tests/testthat/test-renderer5-firefox.R @@ -0,0 +1,23 @@ +acontext("Firefox browser") + +# generate a list of viz +p <- qplot(1:10) +n <- 20 +set.seed(123) # for reproducible random results +random_names <- replicate(n, paste(sample(letters, 5), collapse = "")) +viz <- setNames(replicate(n, p, simplify = FALSE), random_names) + +info <- animint2HTML(viz) + +# Scroll to the bottom of the page +remDr$executeScript("window.scrollTo(0, document.body.scrollHeight);") # remDr is a global variable +Sys.sleep(5) + +# Get current scroll position +scroll_position <- remDr$executeScript("return window.pageYOffset;") +Sys.sleep(5) +new_scroll_position <- remDr$executeScript("return window.pageYOffset;") + +test_that("The scrollbar does not move", { + expect_equal(scroll_position, new_scroll_position, info = "The scrollbar moved.") +}) \ No newline at end of file From aee9513010f0c7098d28b1dac28b856c4f3695e8 Mon Sep 17 00:00:00 2001 From: Faye-yufan Date: Fri, 1 Sep 2023 16:57:48 -0700 Subject: [PATCH 3/3] Remove test temporarily; bug non-reproducible in Firefox v2.53.0 standalone --- inst/htmljs/animint.js | 10 +++++----- tests/testthat/test-renderer5-firefox.R | 23 ----------------------- 2 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 tests/testthat/test-renderer5-firefox.R diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index a31ca49de..43bf034b4 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2392,11 +2392,11 @@ var animint = function (to_select, json_file) { .attr("class", "table_selector_widgets") ; var selector_first_tr = selector_table.append("tr"); - // setTimeout(() => { - // const selector_height = selector_table[0][0].clientHeight; - // selector_table - // .style('height', `${selector_height}px`); - // }, 0); + setTimeout(() => { + const selector_height = selector_table[0][0].clientHeight; + selector_table + .style('height', `${selector_height}px`); + }, 0); selector_first_tr .append("th") .text("Variable") diff --git a/tests/testthat/test-renderer5-firefox.R b/tests/testthat/test-renderer5-firefox.R deleted file mode 100644 index 774184242..000000000 --- a/tests/testthat/test-renderer5-firefox.R +++ /dev/null @@ -1,23 +0,0 @@ -acontext("Firefox browser") - -# generate a list of viz -p <- qplot(1:10) -n <- 20 -set.seed(123) # for reproducible random results -random_names <- replicate(n, paste(sample(letters, 5), collapse = "")) -viz <- setNames(replicate(n, p, simplify = FALSE), random_names) - -info <- animint2HTML(viz) - -# Scroll to the bottom of the page -remDr$executeScript("window.scrollTo(0, document.body.scrollHeight);") # remDr is a global variable -Sys.sleep(5) - -# Get current scroll position -scroll_position <- remDr$executeScript("return window.pageYOffset;") -Sys.sleep(5) -new_scroll_position <- remDr$executeScript("return window.pageYOffset;") - -test_that("The scrollbar does not move", { - expect_equal(scroll_position, new_scroll_position, info = "The scrollbar moved.") -}) \ No newline at end of file