-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat: Add inline editing for tables on desktop #83127
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
Open
mohammadjafarinejad
wants to merge
59
commits into
Expensify:main
Choose a base branch
from
mohammadjafarinejad:fix/82534
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
4d46712
feat: Add inline editing for tables on desktop
mohammadjafarinejad 185f956
feat: Implement inline editing for transactions in search results
mohammadjafarinejad c49ac06
feat: Add Confirm/Cancel button row and enhance date and category pic…
mohammadjafarinejad 7167844
Merge branch 'main' into fix/82534
mohammadjafarinejad ef55b1e
feat: Refactor editable cell styles and improve input handling across…
mohammadjafarinejad 85281f2
Merge branch 'main' into fix/82534
mohammadjafarinejad 2331d98
fix prettier
mohammadjafarinejad 9ad8c73
feat: Enhance inline editing functionality and improve transaction ha…
mohammadjafarinejad f591d6f
fix: Simplify transaction ID retrieval and improve null handling in g…
mohammadjafarinejad 25a33a2
feat: Introduce EditableProps for inline-editable cells and refactor …
mohammadjafarinejad 3ee0dd7
Merge branch 'main' into fix/82534
mohammadjafarinejad 2116cab
refactor: Simplify MerchantOrDescriptionCell rendering in Transaction…
mohammadjafarinejad 90a46cc
feat: Add constants for CategoryPicker popover dimensions
mohammadjafarinejad 37a378c
fix: address codex feedback
mohammadjafarinejad 529f109
fix: center content in editable cell
mohammadjafarinejad 6fb4b95
Merge branch 'main' into fix/82534
mohammadjafarinejad c4fd7e5
fix: incorrect text value
mohammadjafarinejad 0e15ed7
fix: gap above confirm/cancel buttons
mohammadjafarinejad a39e221
fix: close editable cells when clicking outside on search table rows
mohammadjafarinejad ecea587
chore: fix lint
mohammadjafarinejad 411b085
fix: improve editing state handling in TransactionListItem
mohammadjafarinejad 6b5beac
fix: add default value for EditingCellContext
mohammadjafarinejad 0523993
fix: remove isEditable prop from editable cells
mohammadjafarinejad 9551cb5
fix: remove CategoryPickerPopover component
mohammadjafarinejad 33d7d0c
fix: refactor editing cell by using module state
mohammadjafarinejad 82bf64d
fix: update date range in DateCell
mohammadjafarinejad 47acf9c
refactor: remove view wrapper
mohammadjafarinejad e3b50b6
fix: update editableCellHover borderColor
mohammadjafarinejad 94c93a9
Refactor: Simplify showConfirmButtons logic
mohammadjafarinejad 0077b92
Merge branch 'main' into fix/82534
mohammadjafarinejad 8b38c5f
refactor: centralize transaction inline editing via useTransactionInl…
mohammadjafarinejad 50df95a
Merge branch 'main' into fix/82534
mohammadjafarinejad 38979e6
refactor: replace editing cell count with boolean
mohammadjafarinejad f8ba4c4
Merge branch 'Expensify:main' into fix/82534
mohammadjafarinejad 9770aa7
chore: fix lint error
mohammadjafarinejad 1e230ed
Merge branch 'Expensify:main' into fix/82534
mohammadjafarinejad 93048ca
Merge branch 'Expensify:main' into fix/82534
mohammadjafarinejad f6c2509
fix: Prevent onPress event during cell editing in TransactionListItem
mohammadjafarinejad 398c57f
fix: multi-line wrapping
mohammadjafarinejad 362f407
feat: add support for editting tags
mohammadjafarinejad 8deaee8
fix: enable editing for TAG column in search headers
mohammadjafarinejad 6ecc91e
refactor: consolidate picker modal props
mohammadjafarinejad e9432dd
refactor: move TagPicker to folder index
mohammadjafarinejad 971ebee
feat: implement useEffectivePolicyID hook and update transaction edit…
mohammadjafarinejad c82b4af
Merge branch 'Expensify:main' into fix/82534
mohammadjafarinejad a9c846c
feat: auto-cancel editing when canEdit permission is revoked
mohammadjafarinejad dcffdcb
feat: update useInlineEditState hook to include initial editing state…
mohammadjafarinejad 3a94a63
Merge branch 'main' into fix/82534
mohammadjafarinejad 04d542e
fix: sanitize line breaks for single-line inputs in MerchantOrDescrip…
mohammadjafarinejad 738adfb
fix: prevent early return in onPress handler when editing cell
mohammadjafarinejad 3910588
fix: allow event propagation during cell editing in selectFocusedOption
mohammadjafarinejad 3c3c9c4
fix: remove checks for settled and approved reports in transaction ed…
mohammadjafarinejad b256737
fix: prevent line breaks in merchant field
mohammadjafarinejad a2a7ded
fix: pass explicit params to getTransactionEditPermissions instead of…
mohammadjafarinejad 871e9b7
refactor: remove useMemo
mohammadjafarinejad d657c2f
fix: update transaction edit permissions to use OnyxEntry
mohammadjafarinejad 9911ddc
fix: update transaction permissions logic to align with MoneyRequestView
mohammadjafarinejad 097acca
Merge branch 'Expensify:main' into fix/82534
mohammadjafarinejad f93071a
fix: reset submit flag on entering edit mode
mohammadjafarinejad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import React, {useRef, useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import ConfirmCancelButtonRow from '@components/ConfirmCancelButtonRow'; | ||
| import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent'; | ||
| import type PopoverWithMeasuredContentProps from '@components/PopoverWithMeasuredContent/types'; | ||
| import type {ListItem} from '@components/SelectionList/types'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import CONST from '@src/CONST'; | ||
| import CategoryPicker from '.'; | ||
|
|
||
| const DEFAULT_ANCHOR_ALIGNMENT = { | ||
| horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, | ||
| vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP, | ||
| }; | ||
|
|
||
| const popoverDimensions = { | ||
| width: CONST.POPOVER_DROPDOWN_WIDTH, | ||
| height: CONST.POPOVER_DROPDOWN_MAX_HEIGHT, | ||
| }; | ||
|
|
||
| type CategoryPickerModalProps = { | ||
| /** Callback to close the modal */ | ||
| onClose: () => void; | ||
|
|
||
| /** The policy whose categories should be shown */ | ||
| policyID: string | undefined; | ||
|
|
||
| /** Currently selected category */ | ||
| selectedCategory?: string; | ||
|
|
||
| /** Called when the user confirms a category selection */ | ||
| onSelected?: (item: ListItem) => void; | ||
| } & Omit<PopoverWithMeasuredContentProps, 'anchorRef' | 'children' | 'onClose'>; | ||
|
|
||
| function CategoryPickerModal({ | ||
| isVisible, | ||
| onClose, | ||
| anchorPosition, | ||
| policyID, | ||
| selectedCategory, | ||
| onSelected, | ||
| anchorAlignment = DEFAULT_ANCHOR_ALIGNMENT, | ||
| shouldMeasureAnchorPositionFromTop = false, | ||
| }: CategoryPickerModalProps) { | ||
| const styles = useThemeStyles(); | ||
| const StyleUtils = useStyleUtils(); | ||
|
|
||
| // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to distinguish RHL and narrow layout | ||
| // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth | ||
| const {isSmallScreenWidth} = useResponsiveLayout(); | ||
| const anchorRef = useRef<View>(null); | ||
|
|
||
| const [pendingItem, setPendingItem] = useState<ListItem | undefined>(undefined); | ||
|
|
||
| const handleConfirm = () => { | ||
| if (pendingItem) { | ||
| onSelected?.(pendingItem); | ||
| } | ||
| setPendingItem(undefined); | ||
| onClose(); | ||
| }; | ||
|
|
||
| const handleCancel = () => { | ||
| setPendingItem(undefined); | ||
| onClose(); | ||
| }; | ||
|
|
||
| return ( | ||
| <PopoverWithMeasuredContent | ||
| anchorRef={anchorRef} | ||
| isVisible={isVisible} | ||
| onClose={handleCancel} | ||
| anchorPosition={anchorPosition} | ||
| popoverDimensions={popoverDimensions} | ||
| anchorAlignment={anchorAlignment} | ||
| innerContainerStyle={isSmallScreenWidth ? styles.w100 : {width: CONST.POPOVER_DROPDOWN_WIDTH}} | ||
| restoreFocusType={CONST.MODAL.RESTORE_FOCUS_TYPE.DELETE} | ||
| shouldSwitchPositionIfOverflow | ||
| shouldEnableNewFocusManagement | ||
| shouldMeasureAnchorPositionFromTop={shouldMeasureAnchorPositionFromTop} | ||
| shouldSkipRemeasurement | ||
| shouldDisplayBelowModals | ||
| > | ||
| <View style={[StyleUtils.getHeight(CONST.POPOVER_DROPDOWN_MAX_HEIGHT), styles.flexColumn, styles.pt4]}> | ||
| <View style={styles.flex1}> | ||
| <CategoryPicker | ||
| policyID={policyID} | ||
| selectedCategory={pendingItem?.keyForList ?? selectedCategory} | ||
| onSubmit={setPendingItem} | ||
| /> | ||
| </View> | ||
| <ConfirmCancelButtonRow | ||
| onConfirm={handleConfirm} | ||
| onCancel={handleCancel} | ||
| isConfirmDisabled={!pendingItem} | ||
| /> | ||
| </View> | ||
| </PopoverWithMeasuredContent> | ||
| ); | ||
| } | ||
|
|
||
| export default CategoryPickerModal; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import Button from './Button'; | ||
|
|
||
| type ConfirmCancelButtonRowProps = { | ||
| /** Called when the user presses Apply */ | ||
| onConfirm: () => void; | ||
|
|
||
| /** Called when the user presses Cancel */ | ||
| onCancel: () => void; | ||
|
|
||
| /** Whether the Apply button is disabled */ | ||
| isConfirmDisabled?: boolean; | ||
| }; | ||
|
|
||
| function ConfirmCancelButtonRow({onConfirm, onCancel, isConfirmDisabled = false}: ConfirmCancelButtonRowProps) { | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
|
|
||
| return ( | ||
| <View style={[styles.flexRow, styles.gap2, styles.ph4, styles.pb4]}> | ||
| <Button | ||
| style={[styles.flex1]} | ||
| text={translate('common.cancel')} | ||
| onPress={onCancel} | ||
| /> | ||
| <Button | ||
| style={[styles.flex1]} | ||
| success | ||
| text={translate('common.apply')} | ||
| onPress={onConfirm} | ||
| isDisabled={isConfirmDisabled} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default ConfirmCancelButtonRow; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think we need to check
isSmallScreenWidthhere since we only support large screens in this case?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point, but keeping it makes sense in case
CategoryPickerModalgets reused on small screens later. Do you think we should keep it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh! Good point 👍
I think we should make this clearer. Since this file is for web and large screens only, and hasn’t been tested on native or small screens, we should create a web-specific file and have the
.native.tsxversion returnnullwith a comment explaining why.