Commit 83ae2bf5 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Permite al usuario navegar con click + ctrl/shift

Hasta el momento, se capturaba cualquier evento de click sobre enlaces
internos de navegación dentro de la propia SPA, ignorando si el usuario
había pulsado alguna combinación de teclas mientras hizo click. Ahora se
filtran los eventos en los que el usuario ha pulsado la tecla ctrl o
shift para respetar el comportamiento estándar (nueva pestaña o nueva
ventana, respectivamente).

Se omite también la comprobación del botón del ratón pulsado, ya que
actualmente el evento click no se dispara con pulsaciones o toques que
no sean del botón primario.
parent e72956be
Loading
Loading
Loading
Loading
+13 −20
Original line number Diff line number Diff line
@@ -3,17 +3,13 @@ define([
	, 'dojo/_base/lang'
	, 'dojo/dom-attr'
	, 'dojo/io-query'
	, 'dojo/mouse'
	, 'src/component/base/_Module'
	, 'src/component/base/_Store'
], function(
	declare
	, lang
	, domAttr
	, ioQuery
	, mouse
	, _Module
	, _Store
) {

	return declare(_Module, {
@@ -96,13 +92,13 @@ define([
			globalThis.addEventListener.call(globalThis, 'popstate', lang.hitch(this, this._evaluatePopStateEvt));
		},

		_evaluateClickEvt: function(event) {
		_evaluateClickEvt: function(evt) {
			//	summary:
			//		Recibe eventos de click y, en caso de detectar un enlace de navegación interno, lo captura
			//	tags:
			//		private

			var targets = this._getClickTargets(event);
			var targets = this._getClickTargets(evt);

			for (var i = 0; i < targets.length; i++) {
				var target = targets[i],
@@ -112,28 +108,25 @@ define([
					continue;
				}

				this._handleAppHref(event, target);
				this._handleAppHref(evt, target);
				break;
			}
		},

		_handleAppHref: function(event, target) {
		_handleAppHref: function(evt, target) {

			var mustOmitEventHandle = evt.ctrlKey || evt.shiftKey;

			if (mustOmitEventHandle) {
				return;
			}

			var url = target.pathname + target.search + target.hash;

			if (mouse.isMiddle(event)) {
				var newPageUrl = target.protocol + '//' + target.hostname + url;
				globalThis.open(newPageUrl, '_blank');
			} else {
			this._addHistory(url);
			this._onRouteChange();
			}

			if (event.preventDefault) {
				event.preventDefault();
			} else {
				event.returnValue = false;
			}
			evt.preventDefault();
		},

		_addHistory: function(value) {