[ui] Prevent double-open for cmd+click on vars index links (#24316)

* Check for target on click to prevent double-opening cmd+clicked links on var index

* Create cl entry 24316

* Move the dont-open-twice logic into the variable-paths component
This commit is contained in:
Austin Culter
2024-10-29 20:50:09 +01:00
committed by GitHub
parent 5b1ad83d82
commit 3ca728819b
3 changed files with 19 additions and 7 deletions

3
.changelog/24316.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 var
```

View File

@@ -26,13 +26,27 @@ export default class VariablePathsComponent extends Component {
}
@action
async handleFolderClick(path) {
async handleFolderClick(path, 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.path', path);
}
@action
async handleFileClick({ path, variable: { id, namespace } }) {
async handleFileClick({ path, variable: { id, namespace } }, trigger) {
if (this.can.can('read variable', null, { path, namespace })) {
// 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', id);
}
}

View File

@@ -15,11 +15,6 @@ export default class VariablesIndexController extends Controller {
isForbidden = false;
@action
goToVariable(variable) {
this.router.transitionTo('variables.variable', variable.path);
}
@action goToNewVariable() {
this.router.transitionTo('variables.new');
}