Skip to content

Commit f1b9a91

Browse files
committed
fix examples and input focus
1 parent 5949113 commit f1b9a91

File tree

4 files changed

+30
-57
lines changed

4 files changed

+30
-57
lines changed

packages/core/src/components/next/Dropdown/components/Trigger/DropdownInput.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useRef } from "react";
22
import cx from "classnames";
33
import { BaseInput } from "../../../../BaseInput";
44
import styles from "./Trigger.module.scss";
@@ -26,8 +26,8 @@ const DropdownInput = ({ inputSize }: { inputSize?: "small" | "medium" | "large"
2626
getInputProps
2727
} = useDropdownContext<BaseListItemData>();
2828

29+
const inputRef = useRef<HTMLInputElement>(null);
2930
const hasSelection = multi ? selectedItems.length > 0 : !!selectedItem;
30-
3131
const multipleSelectionDropdownProps = getDropdownProps ? getDropdownProps({ preventKeyAction: isOpen }) : {};
3232

3333
return (
@@ -40,6 +40,7 @@ const DropdownInput = ({ inputSize }: { inputSize?: "small" | "medium" | "large"
4040
placeholder: hasSelection ? "" : placeholder,
4141
...multipleSelectionDropdownProps
4242
})}
43+
ref={inputRef}
4344
inputRole="combobox"
4445
value={inputValue || ""}
4546
autoFocus={autoFocus}

packages/docs/src/pages/components/Dropdown/DropdownBasicDropdown.stories.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,7 @@ export const DropdownWithGroups: Story = {
397397
<Flex direction="column" gap="medium">
398398
<Text>Group by category</Text>
399399
<div style={{ width: "300px" }}>
400-
<Dropdown
401-
placeholder="Group by category"
402-
options={options}
403-
maxMenuHeight={170}
404-
clearAriaLabel="Clear"
405-
/>
400+
<Dropdown placeholder="Group by category" options={options} maxMenuHeight={170} clearAriaLabel="Clear" />
406401
</div>
407402
</Flex>
408403
<Flex direction="column" gap="medium">
@@ -665,5 +660,3 @@ export const DropdownWithVirtualization: Story = {
665660
},
666661
name: "Virtualized Dropdown"
667662
};
668-
669-

packages/docs/src/pages/components/Dropdown/DropdownBoxMode.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ The box mode supports multi select option that display as chips. The selected it
5858

5959
<Canvas of={DropdownBoxModeStories.WithIcons} />
6060

61-
## Use cases and examples
62-
63-
### People picker
64-
65-
Can be used when there is a need for selecting people to assign a column
66-
67-
<Canvas of={DropdownBoxModeStories.PeoplePicker} />
68-
6961
## Do's and don'ts
7062

7163
<ComponentRules
@@ -92,6 +84,8 @@ Can be used when there is a need for selecting people to assign a column
9284
type="text"
9385
placeholder="Search menu"
9486
style={{ width: "100%", padding: "8px", border: "1px solid #ddd", borderRadius: "4px" }}
87+
autoFocus={false}
88+
tabIndex={-1}
9589
/>
9690
<div style={{ marginTop: "8px" }}>Category 1</div>
9791
<div>Option 1</div>
@@ -105,7 +99,14 @@ Can be used when there is a need for selecting people to assign a column
10599
]}
106100
/>
107101

102+
## Use cases and examples
103+
104+
### People picker
105+
106+
Can be used when there is a need for selecting people to assign a column
107+
108+
<Canvas of={DropdownBoxModeStories.PeoplePicker} />
109+
108110
## Related components
109111

110112
<RelatedComponents componentsNames={["DropdownBasicSelect", "Combobox", "Menu"]} />
111-

packages/docs/src/pages/components/Dropdown/DropdownBoxMode.stories.tsx

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -261,48 +261,18 @@ export const WithIcons: Story = {
261261
export const PeoplePicker: Story = {
262262
render: () => {
263263
const peopleOptions: any = useMemo(
264-
() => [
265-
{
266-
value: "Matt",
267-
label: "Matt Gaman",
268-
startElement: {
269-
type: "avatar",
270-
value: person1
271-
}
272-
},
273-
{
274-
value: "Jennifer",
275-
label: "Jennifer Lawrence",
276-
startElement: {
277-
type: "avatar",
278-
value: person2
279-
}
280-
},
281-
{
282-
value: "Emma",
283-
label: "Emma Stone",
284-
startElement: {
285-
type: "avatar",
286-
value: person3
287-
}
288-
},
289-
{
290-
value: "Johnny",
291-
label: "Johnny Depp",
292-
startElement: {
293-
type: "avatar",
294-
value: person4
295-
}
296-
}
297-
],
298-
[]
299-
);
300-
301-
const suggestedPeople: any = useMemo(
302264
() => [
303265
{
304266
label: "Suggested people",
305267
options: [
268+
{
269+
value: "Matt",
270+
label: "Matt Gaman",
271+
startElement: {
272+
type: "avatar",
273+
value: person1
274+
}
275+
},
306276
{
307277
value: "Jennifer",
308278
label: "Jennifer Lawrence",
@@ -311,6 +281,14 @@ export const PeoplePicker: Story = {
311281
value: person2
312282
}
313283
},
284+
{
285+
value: "Emma",
286+
label: "Emma Stone",
287+
startElement: {
288+
type: "avatar",
289+
value: person3
290+
}
291+
},
314292
{
315293
value: "Johnny",
316294
label: "Johnny Depp",

0 commit comments

Comments
 (0)