Skip to content

Commit 46a9ce4

Browse files
committed
fix: header search documentation crash and build path bug
1 parent 082adcc commit 46a9ce4

File tree

2 files changed

+47
-11
lines changed

2 files changed

+47
-11
lines changed

packages/react/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"engines": {
88
"node": "^22.13.1"
99
},
10-
"main": "./lib/cjs/index.js",
11-
"module": "./lib/index.js",
12-
"esnext": "./lib/index.js",
13-
"types": "./lib/index.d.ts",
10+
"main": "./cjs/index.js",
11+
"module": "./index.js",
12+
"esnext": "./index.js",
13+
"types": "./index.d.ts",
1414
"sideEffects": [
1515
"base.module*"
1616
],

site/src/docs/components/header/index.mdx

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@ import Notification from '../../../components/Notification';
1111

1212
export default ({ children, pageContext }) => <TabsLayout pageContext={pageContext}>{children}</TabsLayout>;
1313

14+
export const handleSearch = (searchValue) => {
15+
if (searchValue === 'error') {
16+
return Promise.reject(new Error('Simulated error'));
17+
}
18+
19+
// Simple mock options for demo purposes
20+
const mockOptions = [
21+
'Hakutulos 1',
22+
'Hakutulos 2',
23+
'Hakutulos 3',
24+
'Sosiaali- ja terveyspalvelut',
25+
'Kasvatus ja koulutus',
26+
'Asuminen ja ympäristö',
27+
'Kulttuuri ja vapaa-aika',
28+
'Liikenne ja kartat',
29+
'Työ ja yritystoiminta',
30+
'Päätöksenteko ja hallinto'
31+
].filter((label) => label.toUpperCase().indexOf(searchValue.toUpperCase()) >= 0)
32+
.map((label) => ({ value: label, label }));
33+
34+
return Promise.resolve({
35+
groups: [
36+
{
37+
label: 'Hakuehdotukset',
38+
options: mockOptions,
39+
},
40+
],
41+
});
42+
};
43+
1444
## Usage
1545

1646
### Example
@@ -333,9 +363,19 @@ The Header.Search component is to be used for whole site wide search. Currently
333363
menuButtonAriaLabel="Menu"
334364
onMenuClick={(e) => e.stopPropagation()}
335365
>
336-
<Header.ActionBarItem label="Haku" icon={<IconSearch />} id="action-bar-search">
337-
<Header.Search label="Hae palvelusta" onChange={() => {}} onSubmit={() => {}} />
338-
</Header.ActionBarItem>
366+
<Header.Search
367+
texts={{
368+
heading: `Hae palvelusta: Helsingin kaupunki`,
369+
label: 'Mitä etsit?',
370+
buttonLabel: 'Hae',
371+
closeLabel: 'Sulje',
372+
placeholder: 'Anna teksti hakua varten',
373+
assistive: 'Avustava teksti',
374+
}}
375+
onChange={() => {}}
376+
onSubmit={() => {}}
377+
onSearch={handleSearch}
378+
/>
339379
</Header.ActionBar>
340380
</Header>
341381
</PlaygroundPreview>
@@ -344,10 +384,6 @@ The Header.Search component is to be used for whole site wide search. Currently
344384

345385
##### ActionBarItem and ActionBarButton
346386

347-
<Notification label="A work in progress!" className="siteNotification">
348-
The Header.ActionBarItem and Header.ActionBarButton components are subject to change.
349-
</Notification>
350-
351387
The Header.ActionBarItem is a generic component for displaying icon buttons on the action bar accompanied with dropdowns.
352388
Header.ActionBarButton is a generic button component for displaying buttons without dropdowns.
353389

0 commit comments

Comments
 (0)