open-nomad/ui/app/helpers/lazy-click.js
2023-04-10 15:36:59 +00:00

23 lines
476 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Helper from '@ember/component/helper';
/**
* Lazy Click Event
*
* Usage: {{lazy-click action}}
*
* Calls the provided action only if the target isn't an anchor
* that should be handled instead.
*/
export function lazyClick([onClick, event]) {
if (!['a', 'button'].includes(event?.target.tagName.toLowerCase())) {
onClick(event);
}
}
export default Helper.helper(lazyClick);