Bug Fix: company create from people + scroll settings (#545)

This commit is contained in:
Charles Bochet
2023-07-08 18:15:39 -07:00
committed by GitHub
parent ce14d22744
commit 9d25d003ca
9 changed files with 55 additions and 120 deletions

View File

@ -15,6 +15,8 @@ type OwnProps = {
firstValuePlaceholder: string;
secondValuePlaceholder: string;
onChange: (firstValue: string, secondValue: string) => void;
onSubmit?: (firstValue: string, secondValue: string) => void;
onExit?: () => void;
};
const StyledContainer = styled.div`
@ -34,6 +36,8 @@ export function EditableCellDoubleTextEditMode({
firstValuePlaceholder,
secondValuePlaceholder,
onChange,
onSubmit,
onExit,
}: OwnProps) {
const [focusPosition, setFocusPosition] = useState<'left' | 'right'>('left');
@ -53,6 +57,9 @@ export function EditableCellDoubleTextEditMode({
() => {
closeCell();
moveDown();
if (onSubmit) {
onSubmit(firstValue, secondValue);
}
},
InternalHotkeysScope.CellDoubleTextInput,
[closeCell],
@ -61,6 +68,9 @@ export function EditableCellDoubleTextEditMode({
useScopedHotkeys(
Key.Escape,
() => {
if (onExit) {
onExit();
}
closeCell();
},
InternalHotkeysScope.CellDoubleTextInput,
@ -74,6 +84,9 @@ export function EditableCellDoubleTextEditMode({
setFocusPosition('right');
secondValueInputRef.current?.focus();
} else {
if (onExit) {
onExit();
}
closeCell();
moveRight();
}

View File

@ -1,58 +0,0 @@
import { ChangeEvent, useRef } from 'react';
import styled from '@emotion/styled';
type OwnProps = {
leftValue: string;
rightValue: string;
leftValuePlaceholder: string;
rightValuePlaceholder: string;
onChange: (leftValue: string, rightValue: string) => void;
};
const StyledContainer = styled.div`
align-items: center;
display: flex;
justify-content: space-between;
& > input:last-child {
border-left: 1px solid ${({ theme }) => theme.border.color.light};
padding-left: ${({ theme }) => theme.spacing(2)};
}
`;
const StyledEditInplaceInput = styled.input`
height: 18px;
width: 45%;
`;
export function DoubleTextInput({
leftValue,
rightValue,
leftValuePlaceholder,
rightValuePlaceholder,
onChange,
}: OwnProps) {
const firstValueInputRef = useRef<HTMLInputElement>(null);
return (
<StyledContainer>
<StyledEditInplaceInput
autoFocus
placeholder={leftValuePlaceholder}
ref={firstValueInputRef}
value={leftValue}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
onChange(event.target.value, rightValue);
}}
/>
<StyledEditInplaceInput
placeholder={rightValuePlaceholder}
ref={firstValueInputRef}
value={rightValue}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
onChange(leftValue, event.target.value);
}}
/>
</StyledContainer>
);
}

View File

@ -91,12 +91,6 @@ const StyledTableWithHeader = styled.div`
width: 100%;
`;
const StyledTableScrollableContainer = styled.div`
flex: 1;
height: 100%;
overflow: auto;
`;
export function EntityTable<TData extends { id: string }, SortField>({
data,
columns,
@ -137,7 +131,7 @@ export function EntityTable<TData extends { id: string }, SortField>({
availableSorts={availableSorts}
onSortsUpdate={onSortsUpdate}
/>
<StyledTableScrollableContainer ref={tableBodyRef}>
<div ref={tableBodyRef}>
<StyledTable>
<thead>
{table.getHeaderGroups().map((headerGroup) => (
@ -171,7 +165,7 @@ export function EntityTable<TData extends { id: string }, SortField>({
))}
</tbody>
</StyledTable>
</StyledTableScrollableContainer>
</div>
</StyledTableWithHeader>
);
}