-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix: Popover reaction list does not update dynamically #24024
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
Merged
stitesExpensify
merged 15 commits into
Expensify:main
from
tienifr:fix/23752-popover-reaction-list-not-update-dynamically
Aug 8, 2023
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a4a2483
fix: popover reaction list does not update dynamically
tienifr ca3ee00
fix lint
tienifr f162f5d
Merge branch 'main' of https://github.com/tienifr/App into fix/23752-…
tienifr c1e4471
Merge branch 'main' of https://github.com/tienifr/App into fix/23752-…
tienifr c282fa1
add propTypes
tienifr 7c57255
fix lint
tienifr c15b755
rename ref to innerRef
tienifr 34dcfe4
Merge branch 'main' of https://github.com/tienifr/App into fix/23752-…
tienifr 7afde51
showReactionList as callback after setState
tienifr 423bb2f
revert setState approach
tienifr 7982888
Merge branch 'main' of https://github.com/tienifr/App into fix/23752-…
tienifr 2d8d060
optimize re-render
tienifr 4b4d0d7
Merge branch 'main' into fix/23752
tienifr f4578d4
assign ref
tienifr a7295d5
remove redundant param
tienifr 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
55 changes: 55 additions & 0 deletions
55
src/pages/home/report/ReactionList/PopoverReactionList/index.js
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,55 @@ | ||
import React, {forwardRef, useImperativeHandle, useRef, useState} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import BasePopoverReactionList from './BasePopoverReactionList'; | ||
|
||
const propTypes = { | ||
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), | ||
}; | ||
|
||
const defaultProps = { | ||
innerRef: () => {}, | ||
}; | ||
|
||
function PopoverReactionList(props) { | ||
const innerReactionListRef = useRef(); | ||
const [reactionListReportActionID, setReactionListReportActionID] = useState(''); | ||
const [reactionListEmojiName, setReactionListEmojiName] = useState(''); | ||
|
||
/** | ||
* Show the ReactionList modal popover. | ||
* | ||
* @param {Object} [event] - A press event. | ||
* @param {Element} reactionListAnchor - reactionListAnchor | ||
* @param {String} emojiName - Name of emoji | ||
* @param {String} reportActionID - ID of the report action | ||
*/ | ||
const showReactionList = (event, reactionListAnchor, emojiName, reportActionID) => { | ||
setReactionListReportActionID(reportActionID); | ||
setReactionListEmojiName(emojiName); | ||
innerReactionListRef.current.showReactionList(event, reactionListAnchor); | ||
}; | ||
|
||
useImperativeHandle(props.innerRef, () => ({showReactionList}), []); | ||
|
||
return ( | ||
<BasePopoverReactionList | ||
ref={innerReactionListRef} | ||
reportActionID={reactionListReportActionID} | ||
emojiName={reactionListEmojiName} | ||
/> | ||
); | ||
} | ||
|
||
PopoverReactionList.propTypes = propTypes; | ||
PopoverReactionList.defaultProps = defaultProps; | ||
PopoverReactionList.displayName = 'PopoverReactionList'; | ||
|
||
export default React.memo( | ||
forwardRef((props, ref) => ( | ||
<PopoverReactionList | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
innerRef={ref} | ||
/> | ||
)), | ||
); |
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.
Uh oh!
There was an error while loading. Please reload this page.