Skip to content

A platform for community discussion. Free, open, simple.

UX: Enable 'viewport based mobile mode' by default (#35036)

David Taylorab07d114257e
diff --git a/app/assets/javascripts/discourse/app/models/site.js b/app/assets/javascripts/discourse/app/models/site.js
index 68f0dc37fe9..e65e5cde178 100644
--- a/app/assets/javascripts/discourse/app/models/site.js
+++ b/app/assets/javascripts/discourse/app/models/site.js
@@ -121,9 +121,8 @@ export default class Site extends RestModel {
}
deprecated(
- "Accessing `site.mobileView` or `site.desktopView` during the site initialization phase is deprecated. " +
- "In future updates, the mobile mode will be determined by the viewport size and as consequence using " +
- "these values during initialization can lead to errors and inconsistencies when the browser window is " +
+ "Accessing `site.mobileView` or `site.desktopView` during the site initialization " +
+ "can lead to errors and inconsistencies when the browser window is " +
"resized. Please move these checks to a component, transformer, or API callback that executes during page" +
" rendering.",
{
@@ -134,6 +133,10 @@ export default class Site extends RestModel {
);
}
+ if (Mobile.mobileForced) {
+ return true;
+ }
+
if (this.siteSettings.viewport_based_mobile_mode) {
return withSilencedDeprecations(
"discourse.static-viewport-initialization",
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js
index 59e9ec31ac9..cd8c9bdb63b 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js
@@ -155,7 +155,11 @@ acceptance(
assert.dom(".sidebar-container").exists("displays the sidebar");
});
- test("button to toggle between mobile and desktop view on touch devices ", async function (assert) {
+ test("button to toggle between legacy mobile and desktop view on touch devices", async function (assert) {
+ this.container.lookup(
+ "service:site-settings"
+ ).viewport_based_mobile_mode = false;
+
const capabilities = this.container.lookup("service:capabilities");
Sinon.stub(capabilities, "touch").value(true);
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index f938aa57d4f..e7479a19fcf 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -2760,7 +2760,7 @@ en:
view_raw_email_allowed_groups: "Groups which can view the raw email content of a post if it was created by an incoming email. This includes email headers and other technical information."
rich_editor: "Enable the rich editor for the composer so all users can switch between the current Markdown mode and the new rich text editor for more intuitive and user-friendly composition."
default_composition_mode: "Set the default mode for your community's composer. Rich text mode provides a more modern, familiar writing experience for most users, while Markdown mode may be suitable for more technical audiences. Members can use a toggle in the composer toolbar to switch between modes."
- viewport_based_mobile_mode: "EXPERIMENTAL: Disable the user-agent-based mobile/desktop modes and use viewport width instead."
+ viewport_based_mobile_mode: "Use viewport width to determine mobile/desktop modes. This setting will be removed soon. If you find the need to turn it off, please let us know <a href='https://meta.discourse.org/t/384280'>on Meta</a>."
reviewable_ui_refresh: "Groups that can use the experimental new UI in the review queue."
content_localization_enabled: "Displays localized content for users based on their browser or user language preferences. Such content may include categories, tags, posts, and topics. Supported locales are set in 'content localization supported locales'."
content_localization_supported_locales: "List of supported locales that user content can be translated to. Requires 'content localization enabled'."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 44213566b54..87c571315dc 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -3037,7 +3037,7 @@ developer:
hidden: true
client: true
viewport_based_mobile_mode:
- default: false
+ default: true
client: true
navigation:
diff --git a/plugins/chat/spec/system/sidebars_spec.rb b/plugins/chat/spec/system/sidebars_spec.rb
index 399aa8d9244..aa836b8afa3 100644
--- a/plugins/chat/spec/system/sidebars_spec.rb
+++ b/plugins/chat/spec/system/sidebars_spec.rb
@@ -33,9 +33,8 @@ RSpec.describe "Navigation", type: :system do
expect(page).to have_no_css(".channels-list")
end
- context "when visiting on mobile" do
+ context "when visiting on mobile", mobile: true do
it "has no sidebar" do
- visit("/?mobile_view=1")
chat_page.visit_channel(category_channel_2)
expect(page).to have_no_css("#d-sidebar")
@@ -53,9 +52,8 @@ RSpec.describe "Navigation", type: :system do
end
end
- context "when visiting on mobile" do
+ context "when visiting on mobile", mobile: true do
it "has no sidebar" do
- visit("/?mobile_view=1")
chat_page.visit_channel(category_channel_2)
expect(page).to have_no_css(".channels-list")
diff --git a/spec/system/user_page/user_preferences_navigation_spec.rb b/spec/system/user_page/user_preferences_navigation_spec.rb
index 7d5e9a0b088..8eeffd3b73a 100644
--- a/spec/system/user_page/user_preferences_navigation_spec.rb
+++ b/spec/system/user_page/user_preferences_navigation_spec.rb
@@ -7,7 +7,7 @@ describe "User preferences | Navigation menu", type: :system do
describe "when visiting the user's preferences page" do
it "should allow the user to scroll the horizontal navigation menu when window width is narrow" do
- resize_window(width: 400) do
+ resize_window(width: 650) do # narrow enough to hide some links, but higher than 640px so we don't trigger mobile styling
sign_in(user)
user_preferences_page.visit(user)
diff --git a/spec/system/viewing_sidebar_mobile_spec.rb b/spec/system/viewing_sidebar_mobile_spec.rb
index 5519c4f70be..8fb42b63cc4 100644
--- a/spec/system/viewing_sidebar_mobile_spec.rb
+++ b/spec/system/viewing_sidebar_mobile_spec.rb
@@ -59,6 +59,8 @@ describe "Viewing sidebar mobile", type: :system, mobile: true do
end
it "toggles to desktop view after clicking on the toggle to desktop view button" do
+ SiteSetting.viewport_based_mobile_mode = false
+
visit("/latest")
expect(page).to have_css(".mobile-view")