Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/components/Button/validateSubmitShortcut/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type ValidateSubmitShortcut from './types';

const IGNORED_NODE_NAMES = ['TEXTAREA', 'INPUT'];

/**
* Validate if the submit shortcut should be triggered depending on the button state
*
Expand All @@ -13,9 +11,7 @@ const IGNORED_NODE_NAMES = ['TEXTAREA', 'INPUT'];

const validateSubmitShortcut: ValidateSubmitShortcut = (isDisabled, isLoading, event) => {
const eventTarget = event?.target as HTMLElement;

// If the event target node is for an input, such as when there's a stray "Enter" event from an autocomplete input, then ignore it because it's not meant for this button
if (isDisabled || isLoading || IGNORED_NODE_NAMES.includes(eventTarget.nodeName) || (eventTarget?.contentEditable === 'true' && eventTarget.ariaMultiLine)) {
if (isDisabled || isLoading || eventTarget.nodeName === 'TEXTAREA' || (eventTarget?.contentEditable === 'true' && eventTarget.ariaMultiLine)) {
return false;
}

Expand Down