discourse/app/assets/javascripts
Osama Sayegh 8c2c96af25
DEV: Ensure experimental user menu is always closed after clicking on items (#18231)
Because Discourse is a single-page application, clicks on the majority of `<a>` elements in the app need to be intercepted by JavaScript to prevent browsers' default action (full page reload). Links in the user menu - which include notifications, reviewables, bookmarks etc. - are no exception to this rule and currently clicks on these items are handled by the global [click-interceptor](1fa21ed415/app/assets/javascripts/discourse/app/lib/intercept-click.js (L20)) which calls the `preventDefault` function on the click event object and uses the `DiscourseURL.routeTo` function to route the user to the page they request.

However, for links in the user menu, there's an extra step which is to let the header know that it should close the user menu after clicking an item in the menu, but the global interceptor doesn't know that because the step is specific to links in the user menu. This can cause a bug on mobile devices where the menu remains open after clicking on a notification which results in the user having to close the menu to see the page that the notification takes them to.

This commit adds a click handler to user menu items that ensures the menu is closed when an item is clicked and navigates the user to wherever the item links to. There's a small downside to this change which is that user menu items now have their own click interceptor instead of relying on the global interceptor, i.e. duplicated logic, but since it's only a couple of lines, I think we can live with it for a while.

I did try to make the click handler of the user menu items only close the menu (call the `closeUserMenu` function), but for some reasons it caused a full page reload to happen when clicking a notification item due to some weird interactions between the header widget and the user menu. I didn't debug this thoroughly because we have plans to change the header implementation from widgets/virtual-dom to Glimmer component, which will likely resolve that weird full page reload issue and we'll be able to make the click handler just close the menu and let the global interceptor prevents the default action and do the routing.

Internal topic: t/71911/118.
2022-09-13 15:44:45 +03:00
..
admin Build(deps): Bump webpack in /app/assets/javascripts (#18214) 2022-09-11 22:35:55 +02:00
confirm-new-email DEV: Update linting setup and fix issues (#17345) 2022-07-06 10:37:54 +02:00
discourse DEV: Ensure experimental user menu is always closed after clicking on items (#18231) 2022-09-13 15:44:45 +03:00
discourse-common Build(deps): Bump webpack in /app/assets/javascripts (#18214) 2022-09-11 22:35:55 +02:00
discourse-ensure-deprecation-order DEV: Silence 3.x deprecations 2022-07-19 10:00:59 +01:00
discourse-hbr Build(deps): Bump webpack in /app/assets/javascripts (#18214) 2022-09-11 22:35:55 +02:00
discourse-plugins Build(deps): Bump ember-cli-htmlbars in /app/assets/javascripts (#18212) 2022-09-11 14:53:34 +02:00
discourse-widget-hbs Build(deps): Bump webpack in /app/assets/javascripts (#18214) 2022-09-11 22:35:55 +02:00
docs
ember-addons
ember-cli-progress-ci DEV: Add progress output in CI during ember-cli build (#17977) 2022-08-17 22:39:52 +01:00
locales FEATURE: Add Croatian language (#17130) 2022-06-18 00:18:22 +02:00
pretty-text Build(deps): Bump webpack in /app/assets/javascripts (#18214) 2022-09-11 22:35:55 +02:00
select-kit Build(deps): Bump webpack in /app/assets/javascripts (#18214) 2022-09-11 22:35:55 +02:00
truth-helpers Build(deps): Bump webpack in /app/assets/javascripts (#18214) 2022-09-11 22:35:55 +02:00
wizard UX: switch wizard SVG colors for dark mode (#18109) 2022-09-12 11:34:15 -04:00
.licensee.json DEV: Add Ember CLI workspace license checks (#16603) 2022-05-03 13:06:19 -04:00
.npmrc
admin-plugins.js.erb FIX: When using Ember CLI, plugin admin code was not being loaded in tests (#16239) 2022-03-21 15:46:41 -04:00
discourse-js-processor.js DEV: Use DiscourseJsProcessor for theme template compilation (#18135) 2022-09-01 11:50:46 +01:00
handlebars-shim.js
mini-loader.js DEV: Support inline-hbs compilation in themes (#18112) 2022-08-29 19:53:42 +01:00
package.json DEV: Introduce flag for compiling Plugin JS with Ember CLI (#17965) 2022-08-22 09:56:39 +01:00
polyfills.js DEV: Add polyfill for String.prototype.replaceAll (#16301) 2022-03-28 17:18:56 +01:00
service-worker.js.erb FIX: Disable service worker proxying in chrome 97-97.0.4692 (#15638) 2022-01-18 19:41:25 +00:00
yarn.lock Build(deps): Bump mout from 1.2.2 to 1.2.3 in /app/assets/javascripts (#18224) 2022-09-12 11:40:29 +02:00