Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Empty space before SelectFiltered placeholder #171

Merged
merged 4 commits into from
Mar 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/fuselage/src/components/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const Select = ({
}) => {
const [internalValue, setInternalValue] = useState(value);


const currentValue = value !== undefined ? value : internalValue;
const option = options.find((option) => getValue(option) === currentValue);
const index = options.indexOf(option);
Expand Down Expand Up @@ -68,7 +67,7 @@ export const Select = ({

const valueLabel = getLabel(option);

const visibleText = (filter === undefined || visible === AnimatedVisibility.HIDDEN) && (valueLabel || placeholder);
const visibleText = (filter === undefined || visible === AnimatedVisibility.HIDDEN) && (valueLabel || (placeholder || typeof placeholder === 'string'));
return (
<Container disabled={disabled} ref={containerRef} onClick={() => ref.current.focus() & show()} className={
[
Expand All @@ -82,7 +81,7 @@ export const Select = ({
<Flex.Container>
<Margins inline='neg-x4'>
<Wrapper mod-hidden={!!visibleText}>
{ (typeof placeholder === 'string' || !!valueLabel) && <Flex.Item grow={1}>
{ visibleText && <Flex.Item grow={1}>
<Margins inline='x4'>
<Box is='span' textStyle='p2' textColor={ valueLabel ? 'default' : 'hint' }>{visibleText}</Box>
</Margins>
Expand Down