improve font-select min height

main
Mike Fix 5 years ago
parent b6dc55fa24
commit e1147dd887

@ -70,8 +70,6 @@ class Dropdown extends React.PureComponent {
} = this.props } = this.props
const { itemsToShow, inputValue } = this.state const { itemsToShow, inputValue } = this.state
const minWidth = calcMinWidth(itemsToShow)
const labelId = title ? `${title.toLowerCase()}-dropdown` : undefined const labelId = title ? `${title.toLowerCase()}-dropdown` : undefined
return ( return (
@ -89,7 +87,6 @@ class Dropdown extends React.PureComponent {
color, color,
list: itemsToShow, list: itemsToShow,
selected, selected,
minWidth,
itemWrapper, itemWrapper,
icon, icon,
disableInput, disableInput,
@ -101,16 +98,7 @@ class Dropdown extends React.PureComponent {
} }
} }
const renderDropdown = ({ const renderDropdown = ({ color, list, itemWrapper, icon, disableInput, title, labelId }) => ({
color,
list,
minWidth,
itemWrapper,
icon,
disableInput,
title,
labelId
}) => ({
isOpen, isOpen,
highlightedIndex, highlightedIndex,
selectedItem, selectedItem,
@ -120,7 +108,7 @@ const renderDropdown = ({
getItemProps getItemProps
}) => { }) => {
return ( return (
<DropdownContainer {...getRootProps({ refKey: 'innerRef' })} minWidth={minWidth}> <DropdownContainer {...getRootProps({ refKey: 'innerRef' })}>
{title && <VisuallyHidden id={labelId}>{title}</VisuallyHidden>} {title && <VisuallyHidden id={labelId}>{title}</VisuallyHidden>}
<DropdownIcon isOpen={isOpen}>{icon}</DropdownIcon> <DropdownIcon isOpen={isOpen}>{icon}</DropdownIcon>
<SelectedItem <SelectedItem
@ -156,7 +144,7 @@ const renderDropdown = ({
) )
} }
const DropdownContainer = ({ children, innerRef, minWidth, ...rest }) => { const DropdownContainer = ({ children, innerRef, ...rest }) => {
return ( return (
<div {...rest} ref={innerRef} className="dropdown-container"> <div {...rest} ref={innerRef} className="dropdown-container">
{children} {children}
@ -164,7 +152,6 @@ const DropdownContainer = ({ children, innerRef, minWidth, ...rest }) => {
{` {`
.dropdown-container { .dropdown-container {
position: relative; position: relative;
min-width: ${minWidth}px;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
margin-left: 40px; margin-left: 40px;
@ -328,11 +315,4 @@ const ListItem = ({ children, color, isHighlighted, isSelected, itemWrapper, ite
) )
} }
function calcMinWidth(items) {
return items.reduce((max, { name }) => {
const wordSize = name.length * 10 + 32
return wordSize > max ? wordSize : max
}, 0)
}
export default Dropdown export default Dropdown

@ -90,7 +90,7 @@ class ListSetting extends React.Component {
.list { .list {
display: none; display: none;
margin-top: -1px; margin-top: -1px;
max-height: 80px; max-height: 160px;
overflow-y: scroll; overflow-y: scroll;
} }
.is-visible + .list { .is-visible + .list {

Loading…
Cancel
Save