fix(select): limit the maximum height of the dropdown-menu

This commit is contained in:
unix
2020-04-12 08:16:12 +08:00
parent 2dff37cef2
commit 4c914bd5b7
4 changed files with 31 additions and 6 deletions

View File

@@ -19,6 +19,8 @@ interface Props {
onChange?: (value: string) => void
pure?: boolean
className?: string
dropdownClassName?: string
dropdownStyle?: object
}
const defaultProps = {
@@ -34,7 +36,8 @@ export type SelectProps = Props & typeof defaultProps & NativeAttrs
const Select: React.FC<React.PropsWithChildren<SelectProps>> = ({
children, size, disabled, initialValue: init, value: customValue,
icon: Icon, onChange, className, pure, placeholder, ...props
icon: Icon, onChange, className, pure, placeholder, dropdownClassName,
dropdownStyle, ...props
}) => {
const theme = useTheme()
const ref = useRef<HTMLDivElement>(null)
@@ -81,7 +84,9 @@ const Select: React.FC<React.PropsWithChildren<SelectProps>> = ({
<div className={`select ${className}`} ref={ref} onClick={clickHandler} {...props}>
{!value && <span className="value placeholder">{placeholder}</span>}
{value && <span className="value">{selectedChild}</span>}
<SelectDropdown visible={visible}>{children}</SelectDropdown>
<SelectDropdown visible={visible}
className={dropdownClassName}
dropdownStyle={dropdownStyle}>{children}</SelectDropdown>
{!pure && <div className="icon"><Icon /></div>}
<style jsx>{`
.select {