Skip to content

Commit

Permalink
fix(PriorityDropdown): use value not text
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Jun 20, 2023
1 parent 093b97e commit c73e738
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/PriorityDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React from 'react';
import { Button, Dropdown, MenuItem } from '@taskany/bricks';

import { Priority, priorityVariants } from '../types/priority';
Expand All @@ -16,22 +16,25 @@ interface PriorityDropdownProps {

export const PriorityDropdown = React.forwardRef<HTMLDivElement, PriorityDropdownProps>(
({ text, value, disabled, error, onChange }, ref) => {
const items = useMemo(() => Object.keys(priorityVariants).map((p) => getPriorityText(p as Priority)), []);

return (
<Dropdown
ref={ref}
error={error}
text={value || text}
value={value}
onChange={onChange}
items={items}
items={Object.keys(priorityVariants)}
disabled={disabled}
renderTrigger={(props) => (
<Button ref={props.ref} onClick={props.onClick} disabled={props.disabled} text={props.value} />
<Button
ref={props.ref}
onClick={props.onClick}
disabled={props.disabled}
text={getPriorityText(props.value)}
/>
)}
renderItem={(props) => (
<MenuItem ghost key={props.item.id} focused={props.cursor === props.index} onClick={props.onClick}>
<MenuItem ghost key={props.item} focused={props.cursor === props.index} onClick={props.onClick}>
<PriorityText value={props.item} />
</MenuItem>
)}
Expand Down

0 comments on commit c73e738

Please sign in to comment.