diff --git a/README.md b/README.md index b928b39..fff871d 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,19 @@ cd mrujs 2. Install packages ```bash -yarn install +pnpm install ``` ### View Dev Server ```bash -yarn start +pnpm run start ``` ### Run tests ```bash -yarn test +pnpm test ``` ## Rails @@ -65,5 +65,5 @@ Docs are located in `/docs` and use Bridgetown + Netlify. To start the docs server do the following: -`cd docs && yarn install && bundle install && yarn start` +`cd docs && bundle install && bin/bridgetown start` diff --git a/src/method.ts b/src/method.ts index 5e4151a..0ae7081 100644 --- a/src/method.ts +++ b/src/method.ts @@ -2,6 +2,7 @@ import { AJAX_EVENTS, dispatch } from './utils/events' import { EventQueryInterface, MrujsPluginInterface } from '../types' import { addListeners, removeListeners, attachObserverCallback } from './utils/dom' import { MethodSubmission } from './methodSubmission' +import { isInsignificantClick } from './utils/misc' /** * Handles `data-method="method"` submissions. @@ -46,9 +47,11 @@ export function Method (): MrujsPluginInterface { * // Implemented! * Delete */ -export function handleMethod (event: Event): void { +export function handleMethod (event: MouseEvent | Event): void { const element = event.currentTarget as HTMLElement + // Make sure we dont fire on ctrl clicks. + if (event instanceof MouseEvent && isInsignificantClick(event)) { return } if (element.dataset.remote === 'false') return if (element.dataset.method == null && element.dataset.remote !== 'true') return diff --git a/src/utils/misc.ts b/src/utils/misc.ts index ff018b3..3b83851 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -1,6 +1,9 @@ import { stopEverything } from '../utils/events' import { $ } from './dom' +/** + * Any click that we shouldn't handle. + */ export function isInsignificantClick (event: MouseEvent): boolean { return ( ((event.target != null) && (event.target as HTMLElement).isContentEditable) ||