Behaviour Fix on new record addition (#3113)

* Delete record if no company added

* EditMode on First column of new row added

* Fix

* Minor fixes

* Passed scopeId

* Changed FieldInputs to accept onChange handler

* Removed getFieldType

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
Kanav Arora
2024-01-05 22:31:51 +05:30
committed by GitHub
parent 9def3d5b57
commit 8455e15443
28 changed files with 551 additions and 159 deletions

View File

@ -38,6 +38,7 @@ export type DateInputProps = {
) => void;
hotkeyScope: string;
clearable?: boolean;
onChange?: (newDate: Nullable<Date>) => void;
};
export const DateInput = ({
@ -47,6 +48,7 @@ export const DateInput = ({
onEscape,
onClickOutside,
clearable,
onChange,
}: DateInputProps) => {
const theme = useTheme();
@ -66,6 +68,7 @@ export const DateInput = ({
const handleChange = (newDate: Date) => {
setInternalValue(newDate);
onChange?.(newDate);
};
useEffect(() => {

View File

@ -38,6 +38,7 @@ type DoubleTextInputProps = {
event: MouseEvent | TouchEvent,
newDoubleTextValue: FieldDoubleText,
) => void;
onChange?: (newDoubleTextValue: FieldDoubleText) => void;
};
export const DoubleTextInput = ({
@ -51,6 +52,7 @@ export const DoubleTextInput = ({
onEscape,
onShiftTab,
onTab,
onChange,
}: DoubleTextInputProps) => {
const [firstInternalValue, setFirstInternalValue] = useState(firstValue);
const [secondInternalValue, setSecondInternalValue] = useState(secondValue);
@ -70,6 +72,11 @@ export const DoubleTextInput = ({
): void => {
setFirstInternalValue(newFirstValue);
setSecondInternalValue(newSecondValue);
onChange?.({
firstValue: newFirstValue,
secondValue: newSecondValue,
});
};
const [focusPosition, setFocusPosition] = useState<'left' | 'right'>('left');

View File

@ -54,6 +54,7 @@ export type PhoneInputProps = {
onTab?: (newText: string) => void;
onShiftTab?: (newText: string) => void;
onClickOutside: (event: MouseEvent | TouchEvent, inputValue: string) => void;
onChange?: (newText: string) => void;
hotkeyScope: string;
};
@ -66,11 +67,17 @@ export const PhoneInput = ({
onShiftTab,
onClickOutside,
hotkeyScope,
onChange,
}: PhoneInputProps) => {
const [internalValue, setInternalValue] = useState<string | undefined>(value);
const wrapperRef = useRef<HTMLDivElement>(null);
const handleChange = (newValue: string) => {
setInternalValue(newValue);
onChange?.(newValue);
};
useEffect(() => {
setInternalValue(value);
}, [value]);
@ -92,7 +99,7 @@ export const PhoneInput = ({
autoFocus={autoFocus}
placeholder="Phone number"
value={value}
onChange={setInternalValue}
onChange={handleChange}
international={true}
withCountryCallingCode={true}
countrySelectComponent={CountryPickerDropdownButton}

View File

@ -21,6 +21,7 @@ type TextInputProps = {
onShiftTab?: (newText: string) => void;
onClickOutside: (event: MouseEvent | TouchEvent, inputValue: string) => void;
hotkeyScope: string;
onChange?: (newText: string) => void;
};
export const TextInput = ({
@ -33,6 +34,7 @@ export const TextInput = ({
onTab,
onShiftTab,
onClickOutside,
onChange,
}: TextInputProps) => {
const [internalText, setInternalText] = useState(value);
@ -40,6 +42,7 @@ export const TextInput = ({
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
setInternalText(event.target.value);
onChange?.(event.target.value);
};
useEffect(() => {