A platform for community discussion. Free, open, simple.
FIX: Improve mobile card cloak interaction (#38025)
Penar Musaraj9ae86743427a
diff --git a/app/assets/stylesheets/mobile/components/user-card.scss b/app/assets/stylesheets/mobile/components/user-card.scssindex 5b134941567..d6784a35d85 100644--- a/app/assets/stylesheets/mobile/components/user-card.scss+++ b/app/assets/stylesheets/mobile/components/user-card.scss@@ -118,10 +118,23 @@z-index: z("mobile-composer") + 1; // 1101height: 100vh;width: 100vw;- background-color: rgb(black, 0.5);- animation: fadein 0.2s;+ background-color: #000;+ opacity: 0;+ visibility: hidden;+ transition:+ opacity 0.3s,+ visibility 0s 0.3s;++ &.--visible {+ pointer-events: all;+ opacity: 0.6;+ visibility: visible;+ transition:+ opacity 0.3s,+ visibility 0s;+ }@media (prefers-reduced-motion) {- animation-duration: 0s;+ transition-duration: 0s;}}diff --git a/frontend/discourse/app/components/card-container.gjs b/frontend/discourse/app/components/card-container.gjsindex cf904448d4e..51e7577a7a5 100644--- a/frontend/discourse/app/components/card-container.gjs+++ b/frontend/discourse/app/components/card-container.gjs@@ -29,7 +29,7 @@ export default class CardContainer extends Component {<template>{{#if this.site.mobileView}}- <div class="card-cloak hidden"></div>+ <div class="card-cloak"></div>{{/if}}<PluginOutlet @name="user-card-content-container">diff --git a/frontend/discourse/app/components/card-contents-base.js b/frontend/discourse/app/components/card-contents-base.jsindex 44c55479a64..3f9f4fe08d2 100644--- a/frontend/discourse/app/components/card-contents-base.js+++ b/frontend/discourse/app/components/card-contents-base.js@@ -84,7 +84,7 @@ export default class CardContentsBase extends Component {post,});- document.querySelector(".card-cloak")?.classList.remove("hidden");+ document.querySelector(".card-cloak")?.classList.add("--visible");this.appEvents.trigger("user-card:show", { username });// Using `next()` to optimise INP@@ -245,7 +245,7 @@ export default class CardContentsBase extends Component {@bind_hide() {if (!this.visible && this.site.mobileView) {- document.querySelector(".card-cloak")?.classList.add("hidden");+ document.querySelector(".card-cloak")?.classList.remove("--visible");}this._menuInstance?.destroy();diff --git a/spec/system/group_card_spec.rb b/spec/system/group_card_spec.rbindex 31849cae526..419a4a4ff4a 100644--- a/spec/system/group_card_spec.rb+++ b/spec/system/group_card_spec.rb@@ -49,4 +49,17 @@ describe "Group Card", type: :system do)endend++ context "when on mobile", mobile: true do+ it "shows and hides the card cloak when opening and closing the group card" do+ topic_page.visit_topic(topic, post_number: post_with_mention.post_number)+ topic_page.click_mention(post_with_mention, mention)++ expect(page).to have_css(".card-cloak.--visible")++ find(".card-cloak").click++ expect(page).to have_no_css(".card-cloak.--visible")+ end+ endend