Repository navigation
feat(browser): set a default device size for the in-app preview #2966
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
Open
heyitsaadin
wants to merge
20
commits into
Acode-Foundation:main
Choose a base branch
from
heyitsaadin:feat/preview-default-device
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
45289ab
refactor(browser): keep a list of devices in the emulator device list
heyitsaadin 64b915d
refactor(browser): register each device when added to the list
heyitsaadin fc7e8d9
feat(browser): apply the saved default preview size once layout is ready
heyitsaadin fced123
feat(browser): save and restore a default device preview size
heyitsaadin 91f3ca2
feat(browser): add "Set as Default" and "Clear Default" menu items
heyitsaadin 615296b
feat(browser): handle "Set as Default" and "Clear Default" actions
heyitsaadin 8fd2c31
feat(browser): show default menu items only while Devices mode is on
heyitsaadin 4791cba
feat(browser): open the preview in Devices mode when a default is set
heyitsaadin bbf48d8
feat(browser): restore the default preview mode on startup
heyitsaadin 28d28bc
refactor(browser): allow applying desktop mode without reloading
heyitsaadin 752a64c
refactor(browser): make the reload in setDesktopMode optional
heyitsaadin 477aedc
fix(browser): apply saved desktop mode before the first load to avoid…
heyitsaadin e0a18db
fix(browser): only apply dimensions after layout, not desktop mode
heyitsaadin 5a53452
fix(browser): re-fit saved presets to the current screen on restore
heyitsaadin b43da8f
fix(browser): reload once after the saved size is applied
heyitsaadin c7fcd73
fix(browser): don't resize the webview before the emulator is set up
heyitsaadin 4c629f7
fix(browser): add reloadAfterLayout helper, only when a page was requ…
heyitsaadin 1d23d80
fix(browser): show "Clear Default" only when a default is saved
heyitsaadin bf0ec37
fix(browser): refresh default menu items after Set as Default
heyitsaadin 7f4afd8
fix(browser): refresh default menu items after Clear Default
heyitsaadin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The desktop user agent is set before the first load (good), but the first page load still happens at full size, not at the saved size.
BrowserActivity.onCreatecallsbrowser.setUrl(url)right after the constructor, before any layout happens. The saved size only arrives two layout passes later: first the webview's layout listener below, then the emulator's own listener insetReference, which callsrestoreDefaultDevice. So the page starts loading at the full webview width and is resized partway through.CSS media queries will adjust after the resize, but scripts that read
innerWidthor measure the layout once on load will keep the full-size values. A fast localhost server may even finish the page before the resize. Switching Devices on by hand doesn't have this problem, because it reloads after the size is applied.This depends on timing, so could you check it on a device with a page that logs
innerWidthon load? If it reproduces, reload once after the saved size is applied, but only if the page has already started loading.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The page now reloads once after the saved size is applied, and only if a page was already requested.