-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24024 from tienifr/fix/23752-popover-reaction-lis…
…t-not-update-dynamically Fix: Popover reaction list does not update dynamically
- Loading branch information
Showing
3 changed files
with
157 additions
and
67 deletions.
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
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
55 changes: 55 additions & 0 deletions
55
src/pages/home/report/ReactionList/PopoverReactionList/index.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,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} | ||
/> | ||
)), | ||
); |