Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrolling issue in Firefox #92

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions inst/htmljs/animint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the fix is commented, and the tests are still passing, this seems to imply that the test is not sufficient to capture the bug, is that right? @Faye-yufan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, this version of the test cannot capture the bug, I'm thinking of a new way to replicate the bug.

// const selector_height = selector_table[0][0].clientHeight;
// selector_table
// .style('height', `${selector_height}px`);
// }, 0);
selector_first_tr
.append("th")
.text("Variable")
Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/test-renderer5-firefox.R
Original file line number Diff line number Diff line change
@@ -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.")
})