-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 editing the message #24154
Closed
Closed
Fix editing the message #24154
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
78b9f1d
create context to freeze scroll when editing the message and turn off…
Piotrfj 85b5450
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 9ff6e31
refactor of ScrollFrozen context
Piotrfj 45e4736
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 7cb0e91
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 747b378
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 739a7d0
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 23b8e40
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 7936593
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 3a93dd3
bring animation of the scroll back
Piotrfj ce13894
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 592ecf3
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj 292a4a6
fix indents
Piotrfj bd95a39
fix import
Piotrfj 66ded3b
Merge branch 'main' of https://github.com/Expensify/App into fix/1880…
Piotrfj ae3fab6
prettier fix
Piotrfj 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 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,10 @@ | ||
import {useContext} from 'react'; | ||
import {ReportActionListFrozenScrollContext} from '../pages/home/report/ReportActionListFrozenScrollContext'; | ||
|
||
/** | ||
* Hook for getting current state of scroll freeze and a function to set whether the scroll should be frozen | ||
* @returns {Object} | ||
*/ | ||
export default function useFrozenScroll() { | ||
return useContext(ReportActionListFrozenScrollContext); | ||
} |
This file contains 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 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
58 changes: 58 additions & 0 deletions
58
src/pages/home/report/ReportActionListFrozenScrollContext.js
This file contains 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,58 @@ | ||||||||||||||||||
import React, {createContext, forwardRef, useMemo, useState} from 'react'; | ||||||||||||||||||
import PropTypes from 'prop-types'; | ||||||||||||||||||
import getComponentDisplayName from '../../../libs/getComponentDisplayName'; | ||||||||||||||||||
|
||||||||||||||||||
const withScrollFrozenPropTypes = { | ||||||||||||||||||
/** flag determining if we should freeze the scroll */ | ||||||||||||||||||
shouldFreezeScroll: PropTypes.bool, | ||||||||||||||||||
|
||||||||||||||||||
/** Function to update the state */ | ||||||||||||||||||
setShouldFreezeScroll: PropTypes.func, | ||||||||||||||||||
Comment on lines
+7
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
const ReportActionListFrozenScrollContext = createContext(null); | ||||||||||||||||||
|
||||||||||||||||||
function ReportActionListFrozenScrollContextProvider(props) { | ||||||||||||||||||
const [shouldFreezeScroll, setShouldFreezeScroll] = useState(false); | ||||||||||||||||||
|
||||||||||||||||||
/** | ||||||||||||||||||
* The context this component exposes to child components | ||||||||||||||||||
* @returns {Object} flag and a flag setter | ||||||||||||||||||
*/ | ||||||||||||||||||
const contextValue = useMemo( | ||||||||||||||||||
() => ({ | ||||||||||||||||||
shouldFreezeScroll, | ||||||||||||||||||
setShouldFreezeScroll, | ||||||||||||||||||
}), | ||||||||||||||||||
[shouldFreezeScroll, setShouldFreezeScroll], | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
return <ReportActionListFrozenScrollContext.Provider value={contextValue}>{props.children}</ReportActionListFrozenScrollContext.Provider>; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
ReportActionListFrozenScrollContextProvider.displayName = 'ReportActionListFrozenScrollContextProvider'; | ||||||||||||||||||
ReportActionListFrozenScrollContextProvider.propTypes = { | ||||||||||||||||||
/** Actual content wrapped by this component */ | ||||||||||||||||||
children: PropTypes.node.isRequired, | ||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
function withScrollFrozen(WrappedComponent) { | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we creating this HOC? It's not being used anywhere. |
||||||||||||||||||
const WithScrollFrozenState = forwardRef((props, ref) => ( | ||||||||||||||||||
<ReportActionListFrozenScrollContext.Consumer> | ||||||||||||||||||
{(scrollFrozenProps) => ( | ||||||||||||||||||
<WrappedComponent | ||||||||||||||||||
// eslint-disable-next-line react/jsx-props-no-spreading | ||||||||||||||||||
{...scrollFrozenProps} | ||||||||||||||||||
// eslint-disable-next-line react/jsx-props-no-spreading | ||||||||||||||||||
{...props} | ||||||||||||||||||
ref={ref} | ||||||||||||||||||
/> | ||||||||||||||||||
)} | ||||||||||||||||||
</ReportActionListFrozenScrollContext.Consumer> | ||||||||||||||||||
)); | ||||||||||||||||||
|
||||||||||||||||||
WithScrollFrozenState.displayName = `WithScrollFrozenState(${getComponentDisplayName(WrappedComponent)})`; | ||||||||||||||||||
return WithScrollFrozenState; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
export {ReportActionListFrozenScrollContext, ReportActionListFrozenScrollContextProvider, withScrollFrozenPropTypes, withScrollFrozen}; |
This file contains 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
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.
We could improve error handling here.