Skip to content

Commit

Permalink
fix: Minor bug in column scroll in mobile viewport (twentyhq#7448)
Browse files Browse the repository at this point in the history
> [!Note]
> - This PR fixes twentyhq#7447

---------

Co-authored-by: Charles Bochet <[email protected]>
  • Loading branch information
harshit078 and charlesBochet authored Oct 5, 2024
1 parent 4d67787 commit 967e04f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ export const Default: Story = {
await canvas.findByText('Tasks');
await canvas.findByText('People');
await canvas.findByText('Opportunities');
await canvas.findByText('My Customs');
await canvas.findByText('Rockets');
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const meta: Meta<typeof EventRowMainObjectUpdated> = {
},
} as TimelineActivity,
mainObjectMetadataItem: generatedMockObjectMetadataItems.find(
(item) => item.namePlural === 'person',
(item) => item.nameSingular === 'person',
),
},
decorators: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import {
type RecordInlineCellProps = {
readonly?: boolean;
loading?: boolean;
isCentered?: boolean;
};

export const RecordInlineCell = ({
readonly,
loading,
isCentered,
}: RecordInlineCellProps) => {
const { fieldDefinition, recordId } = useContext(FieldContext);
const { fieldDefinition, recordId, isCentered } = useContext(FieldContext);
const buttonIcon = useGetButtonIcon();

const isFieldInputOnly = useIsFieldInputOnly();
Expand Down Expand Up @@ -90,7 +88,7 @@ export const RecordInlineCell = ({
label: fieldDefinition.label,
labelWidth: fieldDefinition.labelWidth,
showLabel: fieldDefinition.showLabel,
isCentered: isCentered,
isCentered,
editModeContent: (
<FieldInput
recordFieldInputdId={getRecordFieldInputId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const StyledValueContainer = styled.div`
display: flex;
flex-grow: 1;
min-width: 0;
position: relative;
`;

const StyledLabelContainer = styled.div<{ width?: number }>`
Expand Down Expand Up @@ -79,7 +80,6 @@ export type RecordInlineCellContainerProps = {
isDisplayModeFixHeight?: boolean;
disableHoverEffect?: boolean;
loading?: boolean;
isCentered?: boolean;
};

export const RecordInlineCellContainer = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { RecordInlineCellContext } from '@/object-record/record-inline-cell/components/RecordInlineCellContext';
import styled from '@emotion/styled';
import { autoUpdate, flip, offset, useFloating } from '@floating-ui/react';
import { useContext } from 'react';
import { createPortal } from 'react-dom';

import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';

const StyledInlineCellEditModeContainer = styled.div`
align-items: center;
display: flex;
width: 100%;
position: absolute;
height: 24px;
margin-left: -${({ theme }) => theme.spacing(1)};
`;

const StyledInlineCellInput = styled.div`
Expand All @@ -34,21 +33,21 @@ type RecordInlineCellEditModeProps = {
export const RecordInlineCellEditMode = ({
children,
}: RecordInlineCellEditModeProps) => {
const { isCentered } = useContext(FieldContext);
const { isCentered } = useContext(RecordInlineCellContext);

const { refs, floatingStyles } = useFloating({
placement: isCentered ? undefined : 'right-start',
placement: isCentered ? 'bottom' : 'bottom-start',
middleware: [
flip(),
offset(
isCentered
? {
mainAxis: -32,
crossAxis: 160,
mainAxis: -26,
crossAxis: 0,
}
: {
mainAxis: -28,
crossAxis: -4,
mainAxis: -4,
},
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ export const RecordShowContainer = ({
},
useUpdateRecord: useUpdateOneObjectRecordMutation,
hotkeyScope: InlineCellHotkeyScope.InlineCell,
isCentered: true,
isCentered: !isMobile,
}}
>
<RecordInlineCell readonly={isReadOnly} isCentered={true} />
<RecordInlineCell readonly={isReadOnly} />
</FieldContext.Provider>
}
avatarType={recordIdentifier?.avatarType ?? 'rounded'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const StyledTableHead = styled.thead<{
clip-path: inset(0px -4px 0px 0px);
}
@media (max-width: ${MOBILE_VIEWPORT}px) {
width: 35px;
width: 30px;
max-width: 35px;
}
}
Expand Down

0 comments on commit 967e04f

Please sign in to comment.