mirror of
https://github.com/discourse/discourse.git
synced 2025-05-26 10:42:10 +08:00
DEV: Defer button actions with layout change to the next frame paint (#27967)
User actions can trigger functions that render changes to the screen within the same cycle (e.g. pressing the reply button will cause the login modal to pop up), potentially impacting performance and causing some jank on slower devices. This change inserts runAfterFramePaint where certain actions are triggered. Below are some screenshots indicating an improved INP for some of the buttons affected on controls with the highest INPs. The two places where this is added help with several actions, e.g. user + group cards, generic button action usage.
This commit is contained in:
@ -34,6 +34,10 @@ describe "Homepage", type: :system do
|
||||
|
||||
# Wait for the save to complete
|
||||
find(".btn-primary.save-changes:not([disabled])", wait: 5)
|
||||
try_until_success do
|
||||
visit "/u/#{user.username}/preferences/interface"
|
||||
homepage_picker.has_selected_name?("Top")
|
||||
end
|
||||
|
||||
visit "/"
|
||||
|
||||
@ -89,9 +93,12 @@ describe "Homepage", type: :system do
|
||||
homepage_picker.select_row_by_name("Top")
|
||||
page.find(".btn-primary.save-changes").click
|
||||
|
||||
# Wait for the save to complete
|
||||
# Make sure save is complete
|
||||
find(".btn-primary.save-changes:not([disabled])", wait: 5)
|
||||
expect(user.user_option.homepage_id).to eq(UserOption::HOMEPAGES.key("top"))
|
||||
try_until_success do
|
||||
visit "/u/#{user.username}/preferences/interface"
|
||||
homepage_picker.has_selected_name?("Top")
|
||||
end
|
||||
|
||||
find("#site-logo").click
|
||||
expect(page).to have_css(".navigation-container .top.active", text: "Top")
|
||||
@ -107,7 +114,10 @@ describe "Homepage", type: :system do
|
||||
|
||||
# Wait for the save to complete
|
||||
find(".btn-primary.save-changes:not([disabled])", wait: 5)
|
||||
expect(user.reload.user_option.homepage_id).to_not eq(UserOption::HOMEPAGES.key("top"))
|
||||
try_until_success do
|
||||
visit "/u/#{user.username}/preferences/interface"
|
||||
homepage_picker.has_selected_name?("(default)")
|
||||
end
|
||||
|
||||
find("#site-logo").click
|
||||
|
||||
|
Reference in New Issue
Block a user