diff --git a/src/components/button/Primary.vue b/src/components/button/Primary.vue index 7ca3b98..40f7bc0 100644 --- a/src/components/button/Primary.vue +++ b/src/components/button/Primary.vue @@ -26,6 +26,7 @@ :disabled="disabled" :tabindex="loading ? '-1' : '0'" role="button" + @keydown="handleKeypress" > (), { +const props = withDefaults(defineProps(), { to: "", exact: true, blank: false, @@ -103,4 +104,11 @@ withDefaults(defineProps(), { outline: false, shortcut: () => [], }) - + +const handleKeypress = (event: KeyboardEvent) => { + // Check if the button is in a loading state + if (props.loading && (event.key === "Enter" || event.key === " ")){ + event.preventDefault(); + } +}; + \ No newline at end of file diff --git a/src/stories/Button.story.vue b/src/stories/Button.story.vue index e1dbead..c51e354 100644 --- a/src/stories/Button.story.vue +++ b/src/stories/Button.story.vue @@ -11,4 +11,4 @@ + \ No newline at end of file diff --git a/src/stories/Keypress.story.vue b/src/stories/Keypress.story.vue new file mode 100644 index 0000000..b56c674 --- /dev/null +++ b/src/stories/Keypress.story.vue @@ -0,0 +1,70 @@ + + + + \ No newline at end of file