Skip to content

Commit

Permalink
Check for target on click to prevent double-opening cmd+clicked links…
Browse files Browse the repository at this point in the history
… on var index
  • Loading branch information
ChefAustin authored Oct 29, 2024
1 parent 2df473c commit 6b6d23a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ui/app/controllers/variables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import Controller, { inject as controller } from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
// eslint-disable-next-line no-unused-vars
import VariableModel from '../../models/variable';

const ALL_NAMESPACE_WILDCARD = '*';

Expand All @@ -15,8 +17,20 @@ export default class VariablesIndexController extends Controller {

isForbidden = false;

/**
* Trigger can either be the pointer event itself, or if the keyboard shorcut was used, the html element corresponding to the variable.
* @param {VariableModel} variable
* @param {PointerEvent|HTMLElement} trigger
*/
@action
goToVariable(variable) {
goToVariable(variable, trigger) {
// Don't navigate if the user clicked on a link; this will happen with modifier keys like cmd/ctrl on the link itself
if (
trigger instanceof PointerEvent &&
/** @type {HTMLElement} */ (trigger.target).tagName === 'A'
) {
return;
}
this.router.transitionTo('variables.variable', variable.path);
}

Expand Down

0 comments on commit 6b6d23a

Please sign in to comment.