left_sidebar: Stop event propagation on DM filter click.

Before this, in the onclick event for
`#direct-messages-section-header.zoom-in`, we were filtering out the
class for the direct messages filter, and not activating a narrow on
trying to input on the filter. This was fragile, so we've added an
onclick listener to the direct messages filter which will do nothing
else than stopping the event propagation upto direct messages section
header.
Fixes https://github.com/zulip/zulip/pull/30332#discussion_r1669198527.
This commit is contained in:
Shubham Padia 2024-07-10 07:41:50 +00:00 committed by Tim Abbott
parent 6c3707f484
commit a2f2b52c2d
1 changed files with 8 additions and 7 deletions

View File

@ -774,13 +774,14 @@ export function initialize() {
e.preventDefault();
e.stopPropagation();
if (!$(e.target).hasClass("direct-messages-list-filter")) {
// Avoiding having clicks on the filter input.
//
// TODO: Refactor to use more precise selectors for this
// click handler in general; this is a fragile pattern.
window.location.hash = "narrow/is/dm";
}
window.location.hash = "narrow/is/dm";
});
$("body").on("click", ".direct-messages-list-filter", (e) => {
// We don't want clicking on the filter to trigger the DM
// narrow defined on click for
// `#direct-messages-section-header.zoom-in`.
e.stopPropagation();
});
// disable the draggability for left-sidebar components