Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit efbe58a

Browse files
authored
fix: placeholder to select element (#9905)
1 parent eaa367c commit efbe58a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

components/Tabs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import Select from "@components/form/Select";
22
import { classNames } from "@services/utils/classNames";
33

4-
export default function Tabs({ tabs, setTabs, selectedTab }) {
4+
export default function Tabs({ tabs, setTabs, selectedTab, placeholder }) {
55
return (
66
<div>
77
<div className="sm:hidden">
88
{tabs.length > 1 && (
99
<Select
1010
name="tabs"
1111
value={selectedTab?.name}
12+
placeholder={placeholder}
1213
onChange={(e) =>
1314
setTabs(tabs.find((tab) => tab.name === e.currentTarget.value))
1415
}

components/form/Select.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { classNames } from "@services/utils/classNames";
22
import Label from "./Label";
33

44
export default function Select({
5-
value,
5+
value = "",
66
onChange,
77
options = [],
88
label,
99
name,
1010
className,
11+
placeholder,
1112
...restProps
1213
}) {
1314
return (
@@ -27,6 +28,11 @@ export default function Select({
2728
)}
2829
{...restProps}
2930
>
31+
{placeholder && (
32+
<option value="" disabled>
33+
{placeholder}
34+
</option>
35+
)}
3036
{options.map((option) => (
3137
<option
3238
className="checked:text-secondary-high checked:font-bold dark:checked:text-secondary-low-high"

components/navbar/SubNav.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,12 @@ export default function SubNav({ tabs }) {
1212
});
1313
};
1414

15-
return <Tabs tabs={tabs} setTabs={changeTab} selectedTab={selectedTab} />;
15+
return (
16+
<Tabs
17+
tabs={tabs}
18+
setTabs={changeTab}
19+
selectedTab={selectedTab}
20+
placeholder="Choose a category"
21+
/>
22+
);
1623
}

0 commit comments

Comments
 (0)