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: fix regression on multiItem input field when no item #9543

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import { useCombinedRefs } from '~/hooks/useCombinedRefs';
const StyledInput = styled.input<{
withRightComponent?: boolean;
hasError?: boolean;
hasItem: boolean;
}>`
${TEXT_INPUT_STYLE}

background-color: ${({ theme }) => theme.background.transparent.lighter};
border-radius: 4px;
border: 1px solid ${({ theme }) => theme.border.color.medium};
${({ hasItem, theme }) =>
hasItem &&
css`
background-color: ${theme.background.transparent.lighter};
border-radius: 4px;
border: 1px solid ${theme.border.color.medium};
`}

box-sizing: border-box;
font-weight: ${({ theme }) => theme.font.weight.medium};
Expand Down Expand Up @@ -70,6 +75,7 @@ export type MultiItemBaseInputProps = HTMLInputProps & {
}) => React.ReactNode;
error?: string | null;
hasError?: boolean;
hasItem: boolean;
};

export const MultiItemBaseInput = forwardRef<
Expand All @@ -93,6 +99,7 @@ export const MultiItemBaseInput = forwardRef<
renderInput,
error = '',
hasError = false,
hasItem,
},
ref,
) => {
Expand Down Expand Up @@ -129,6 +136,7 @@ export const MultiItemBaseInput = forwardRef<
onChange={onChange}
ref={combinedRef}
withRightComponent={!!rightComponent}
hasItem={hasItem}
/>
)}
{!!rightComponent && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export const MultiItemFieldInput = <T,>({
)
}
onEnter={handleSubmitInput}
hasItem={!!items.length}
rightComponent={
items.length ? (
<LightIconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ import { MultiItemFieldInput } from './MultiItemFieldInput';

import { createPhonesFromFieldValue } from '@/object-record/record-field/meta-types/input/utils/phonesUtils';
import { PhoneCountryPickerDropdownButton } from '@/ui/input/components/internal/phone/components/PhoneCountryPickerDropdownButton';
import { css } from '@emotion/react';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { stripSimpleQuotesFromString } from '~/utils/string/stripSimpleQuotesFromString';

export const DEFAULT_PHONE_CALLING_CODE = '1';

const StyledCustomPhoneInputContainer = styled.div`
background-color: ${({ theme }) => theme.background.transparent.lighter};
border-radius: 4px;
border: 1px solid ${({ theme }) => theme.border.color.medium};
height: 30px;
const StyledCustomPhoneInputContainer = styled.div<{
hasItem: boolean;
}>`
${({ hasItem, theme }) =>
hasItem &&
css`
background-color: ${theme.background.transparent.lighter};
border-radius: 4px;
border: 1px solid ${theme.border.color.medium};
height: 30px;
etiennejouan marked this conversation as resolved.
Show resolved Hide resolved
`}
`;

const StyledCustomPhoneInput = styled(ReactPhoneNumberInput)`
Expand Down Expand Up @@ -130,7 +137,7 @@ export const PhonesFieldInput = ({
)}
renderInput={({ value, onChange, autoFocus, placeholder }) => {
return (
<StyledCustomPhoneInputContainer>
<StyledCustomPhoneInputContainer hasItem={!!phones.length}>
<StyledCustomPhoneInput
autoFocus={autoFocus}
placeholder={placeholder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const StyledDropdownButtonContainer = styled.div<StyledDropdownButtonProps>`
cursor: pointer;
display: flex;
height: 30px;
height: 32px;
padding-left: ${({ theme }) => theme.spacing(2)};
padding-right: ${({ theme }) => theme.spacing(1)};
Expand Down
Loading