Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

popovers: Skip updating url hash when clicked on "View user profile".

roanster007c9667048b7c2
diff --git a/web/src/user_card_popover.js b/web/src/user_card_popover.js
index 730ca43d99a..d8e8fb3ac78 100644
--- a/web/src/user_card_popover.js
+++ b/web/src/user_card_popover.js
@@ -19,6 +19,7 @@ import * as compose_ui from "./compose_ui";
import * as confirm_dialog from "./confirm_dialog";
import {show_copied_confirmation} from "./copied_tooltip";
import * as dialog_widget from "./dialog_widget";
+import {is_overlay_hash} from "./hash_parser";
import * as hash_util from "./hash_util";
import {$t_html} from "./i18n";
import * as message_lists from "./message_lists";
@@ -637,7 +638,15 @@ function register_click_handlers() {
$("body").on("click", ".user-card-popover-actions .view_full_user_profile", (e) => {
const user_id = elem_to_user_id($(e.target).parents("ul"));
- browser_history.go_to_location(`user/${user_id}`);
+ const current_hash = window.location.hash;
+ // If any overlay is already open, we want the user profile to behave
+ // as a modal rather than an overlay.
+ if (is_overlay_hash(current_hash)) {
+ const user = people.get_by_user_id(user_id);
+ user_profile.show_user_profile(user);
+ } else {
+ browser_history.go_to_location(`user/${user_id}`);
+ }
e.stopPropagation();
e.preventDefault();
});
diff --git a/web/src/user_profile.js b/web/src/user_profile.js
index 01376c58770..3ac4385de81 100644
--- a/web/src/user_profile.js
+++ b/web/src/user_profile.js
@@ -25,6 +25,7 @@ import {csrf_token} from "./csrf";
import * as custom_profile_fields_ui from "./custom_profile_fields_ui";
import * as dialog_widget from "./dialog_widget";
import * as dropdown_widget from "./dropdown_widget";
+import {get_current_hash_category} from "./hash_parser";
import * as hash_util from "./hash_util";
import {$t, $t_html} from "./i18n";
import * as integration_url_modal from "./integration_url_modal";
@@ -392,7 +393,14 @@ export function hide_user_profile() {
function on_user_profile_hide() {
user_streams_list_widget = undefined;
user_profile_subscribe_widget = undefined;
- browser_history.exit_overlay();
+ const base = get_current_hash_category();
+ // After closing the user profile, if the hash consists of `#user`
+ // it means that it acts as an overlay rather than a modal (when
+ // no other overlay is in the background). Hence, we also need to
+ // update the hash when we close it.
+ if (base === "user") {
+ browser_history.exit_overlay();
+ }
}
function show_manage_user_tab(target) {