From b40cb4e2dd81d4b09b4d587cafbaabc9e6a9da18 Mon Sep 17 00:00:00 2001 From: Sean Erik Scully Date: Thu, 30 Jan 2025 22:21:45 +0100 Subject: [PATCH] fix: on enter not working in auto complete --- lib/components/Search/Autocomplete.tsx | 5 ++--- package.json | 10 ++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/components/Search/Autocomplete.tsx b/lib/components/Search/Autocomplete.tsx index caef807..fdef34a 100644 --- a/lib/components/Search/Autocomplete.tsx +++ b/lib/components/Search/Autocomplete.tsx @@ -6,7 +6,7 @@ import { AutocompleteItem, type AutocompleteItemProps, } from '..'; -import { useMenu } from '../../hooks/index.ts'; +import { useMenu } from '../../hooks'; import { useEnterKey } from '../../hooks/useEnterKey.ts'; export interface AutocompleteProps { @@ -22,8 +22,7 @@ export const Autocomplete = ({ className, items, groups = {}, expanded, onSelect useEnterKey(() => { const activeItem = ref.current?.querySelector('[data-active="true"]') as HTMLElement | null; - const firstInteractiveItem = activeItem?.querySelector('a, button'); - firstInteractiveItem?.dispatchEvent(new MouseEvent('click', { bubbles: true })); + activeItem?.dispatchEvent(new MouseEvent('click', { bubbles: true })); onSelect?.(); }); diff --git a/package.json b/package.json index e561699..4758a5f 100644 --- a/package.json +++ b/package.json @@ -2,17 +2,11 @@ "name": "@altinn/altinn-components", "version": "0.15.2", "main": "dist/index.js", - "files": [ - "dist/", - "!dist/stories/", - "!dist/components/*/*.stories.js" - ], + "files": ["dist/", "!dist/stories/", "!dist/components/*/*.stories.js"], "types": "dist/types/lib/index.d.ts", "type": "module", "description": "Reusable react components", - "sideEffects": [ - "*.css" - ], + "sideEffects": ["*.css"], "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "storybook": "storybook dev -p 6006",