-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add StudioSearch component #14348
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jeg ser at det er gjort på denne måten enkelte andre steder, men for å følge fasademønsteret, bør vi egentlig lage en egen komponent rundt designsystemkomponenten. Da kan vi også sette size='sm'
som standard og ta i bruk WithoutAsChild
på prop-typen.
Vi har et søkefelt på dashbordet også. Hvis det ikke er for mye jobb, kan du legge den til der i tillegg? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14348 +/- ##
=======================================
Coverage 95.54% 95.54%
=======================================
Files 1862 1864 +2
Lines 24125 24134 +9
Branches 2785 2785
=======================================
+ Hits 23050 23060 +10
Misses 817 817
+ Partials 258 257 -1 ☔ View full report in Codecov by Sentry. |
frontend/libs/studio-components/src/components/StudioSearch/StudioSearch.test.tsx
Outdated
Show resolved
Hide resolved
50c0a82
to
2679d7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Var litt rask med å godkjenne denne. Se kommentar.
<Label>{label}</Label> | ||
<Search {...rest} size={size} ref={ref} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Når vi bruker label
, må vi bruke htmlFor
til å referere til riktig felt. Dette refererer til HTML-attributtet for
. ID-en kan vi generere ved hjelp av useId
.
<Label>{label}</Label> | |
<Search {...rest} size={size} ref={ref} /> | |
<Label htmlFor={id}>{label}</Label> | |
<Search {...rest} id={id} size={size} ref={ref} /> |
Dette kan vi verifisere med en test som bruker screen.getByRole('searchbox', { name: label })
til å finne søkefeltet.
For øvrig lurer jeg på hva som er hensikten med StudioFieldset
her?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skal fikse!
StudiofieldSet la jeg til fordi DS hadde dette kodeeksempelet bare. Men jeg er på tynn is her, så godt mulig det ikke er riktig! https://storybook.designsystemet.no/iframe.html?viewMode=docs&id=komponenter-search--docs&globals=#med-label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dette eksemplet bruker de Field
, ikke Fieldset
. Jeg går ut fra at dette er noe som er lagt til versjon 1 for å fikse dette med ID automatisk.
return showLabel ? ( | ||
<StudioFieldset legend={legend}> | ||
<Label htmlFor='searchId'>{label}</Label> | ||
<Search {...rest} id='searchId' size={size} ref={ref} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vi bør ikke hardkode ID-en. En ID må være unik, så dette vil gjøre DOM-en ugyldig hvis siden inneholder flere søkefelter. Derfor bør vi generere en unik ID med useId
. Vi bør også sjekke om det allerede er satt in ID i proppene. I så fall er det den som skal gjelde.
testCustomAttributes(renderTestSearch, getSearchBox); | ||
}); | ||
|
||
it('should find search component with label name', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('should find search component with label name', () => { | |
it('should render search field with label name', () => { |
Description
StudioSearch
component.Dashboard:
nt on dashboard.
Text-editor:
CodeLists in content library:
Related Issue(s)
Verification