Check for target on click to prevent double-opening cmd+clicked links on jobs index (#23832)

This commit is contained in:
Phil Renaud
2024-08-19 10:20:24 -04:00
committed by GitHub
parent d6be784e2d
commit fbd8d62955
2 changed files with 18 additions and 1 deletions

3
.changelog/23832.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
ui: Fix an issue where cmd+click or ctrl+click would double-open a job
```

View File

@@ -12,6 +12,8 @@ import { tracked } from '@glimmer/tracking';
import localStorageProperty from 'nomad-ui/utils/properties/local-storage';
import { restartableTask, timeout } from 'ember-concurrency';
import Ember from 'ember';
// eslint-disable-next-line no-unused-vars
import JobModel from '../../models/job';
const JOB_LIST_THROTTLE = 5000;
const JOB_DETAILS_THROTTLE = 1000;
@@ -62,8 +64,20 @@ export default class JobsIndexController extends Controller {
@tracked pendingJobs = null;
@tracked pendingJobIDs = null;
/**
* Trigger can either be the pointer event itself, or if the keyboard shorcut was used, the html element corresponding to the job.
* @param {JobModel} job
* @param {PointerEvent|HTMLElement} trigger
*/
@action
gotoJob(job) {
gotoJob(job, 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('jobs.job.index', job.idWithNamespace);
}