-
Notifications
You must be signed in to change notification settings - Fork 3.3k
PR 3: Adding EmojiPicker to the Edit Comment #7580
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
Julesssss
merged 18 commits into
Expensify:main
from
mananjadhav:feat/emoji-picker-in-edit-message
Mar 30, 2022
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
105e260
feat: Added EmojiPicker in Edit Comment
mananjadhav cfe4f80
feat: Added props to ReportActionItem
mananjadhav 9e069e9
feat: Removed onBeforeShowEmojiPicker for EmojiPicker
mananjadhav 9106221
Merge branch 'main' of https://github.com/mananjadhav/App into feat/e…
mananjadhav 401fc2b
Merge branch 'main' of https://github.com/mananjadhav/App into feat/e…
mananjadhav f1d8e58
feat: Updated condition for edit message emojipicker
mananjadhav 15ac99b
Merge branch 'main' of https://github.com/mananjadhav/App into feat/e…
mananjadhav 6f34743
Merge branch 'main' of https://github.com/mananjadhav/App into feat/e…
mananjadhav 3fd3690
fix: show emojipicker only aftr anchor position is measured
mananjadhav 74ea882
fix: add focus to edit comment on emoji selection
mananjadhav 9317bcb
fix: code cleanup
mananjadhav 6d5ef67
fix: Removed extra space
mananjadhav f7043d6
Merge branch 'main' of https://github.com/mananjadhav/App into feat/e…
mananjadhav b5d1258
fix: split measure anchor position and update state
mananjadhav 202cecd
fix: added this binding to measure function
mananjadhav eabc817
Merge branch 'main' of https://github.com/mananjadhav/App into feat/e…
mananjadhav 38a602e
fix: added margin to emoji button in edit mode
mananjadhav dac1391
Merge branch 'main' of https://github.com/mananjadhav/App into feat/e…
mananjadhav 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
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 |
---|---|---|
|
@@ -14,8 +14,11 @@ import withLocalize, {withLocalizePropTypes} from '../../../components/withLocal | |
import Button from '../../../components/Button'; | ||
import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFocusManager'; | ||
import compose from '../../../libs/compose'; | ||
import EmojiPickerButton from '../../../components/EmojiPicker/EmojiPickerButton'; | ||
import * as ReportUtils from '../../../libs/reportUtils'; | ||
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu'; | ||
import VirtualKeyboard from '../../../libs/VirtualKeyboard'; | ||
import * as User from '../../../libs/actions/User'; | ||
|
||
const propTypes = { | ||
/** All the data of the action */ | ||
|
@@ -33,6 +36,18 @@ const propTypes = { | |
/** A ref to forward to the text input */ | ||
forwardedRef: PropTypes.func, | ||
|
||
/** The report currently being looked at */ | ||
report: PropTypes.shape({ | ||
/** Participants associated with current report */ | ||
participants: PropTypes.arrayOf(PropTypes.string), | ||
}), | ||
|
||
// The NVP describing a user's block status | ||
blockedFromConcierge: PropTypes.shape({ | ||
// The date that the user will be unblocked | ||
expiresAt: PropTypes.string, | ||
}), | ||
|
||
/** Window Dimensions Props */ | ||
...windowDimensionsPropTypes, | ||
|
||
|
@@ -42,6 +57,8 @@ const propTypes = { | |
|
||
const defaultProps = { | ||
forwardedRef: () => {}, | ||
report: {}, | ||
blockedFromConcierge: {}, | ||
}; | ||
|
||
class ReportActionItemMessageEdit extends React.Component { | ||
|
@@ -53,6 +70,7 @@ class ReportActionItemMessageEdit extends React.Component { | |
this.publishDraft = this.publishDraft.bind(this); | ||
this.triggerSaveOrCancel = this.triggerSaveOrCancel.bind(this); | ||
this.onSelectionChange = this.onSelectionChange.bind(this); | ||
this.addEmojiToTextBox = this.addEmojiToTextBox.bind(this); | ||
|
||
const parser = new ExpensiMark(); | ||
const draftMessage = parser.htmlToMarkdown(this.props.draftMessage); | ||
|
@@ -139,6 +157,21 @@ class ReportActionItemMessageEdit extends React.Component { | |
this.deleteDraft(); | ||
} | ||
|
||
/** | ||
* @param {String} emoji | ||
*/ | ||
addEmojiToTextBox(emoji) { | ||
const newComment = this.state.draft.slice(0, this.state.selection.start) | ||
+ emoji + this.state.draft.slice(this.state.selection.end, this.state.draft.length); | ||
this.setState(prevState => ({ | ||
selection: { | ||
start: prevState.selection.start + emoji.length, | ||
end: prevState.selection.start + emoji.length, | ||
}, | ||
})); | ||
this.updateDraft(newComment); | ||
} | ||
|
||
/** | ||
* Key event handlers that short cut to saving/canceling. | ||
* | ||
|
@@ -155,6 +188,10 @@ class ReportActionItemMessageEdit extends React.Component { | |
} | ||
|
||
render() { | ||
const shouldDisableEmojiPicker = (ReportUtils.chatIncludesConcierge(this.props.report) | ||
&& User.isBlockedFromConcierge(this.props.blockedFromConcierge)) | ||
|| ReportUtils.isArchivedRoom(this.props.report); | ||
|
||
return ( | ||
<View style={styles.chatItemMessage}> | ||
<View style={[styles.chatItemComposeBox, styles.flexRow, styles.chatItemComposeBoxColor]}> | ||
|
@@ -176,6 +213,14 @@ class ReportActionItemMessageEdit extends React.Component { | |
selection={this.state.selection} | ||
onSelectionChange={this.onSelectionChange} | ||
/> | ||
<View style={styles.editChatItemEmojiWrapper}> | ||
<EmojiPickerButton | ||
isDisabled={shouldDisableEmojiPicker} | ||
onModalHide={() => InteractionManager.runAfterInteractions(() => this.textInput.focus())} | ||
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. Coming from #30119 If, at the beginning, a composer's emoji picker is open, opening some other emoji picker results in a race:
|
||
onEmojiSelected={this.addEmojiToTextBox} | ||
/> | ||
</View> | ||
|
||
</View> | ||
<View style={[styles.flexRow, styles.mt1]}> | ||
<Button | ||
|
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
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.