Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit dfb013b

Browse files
committed
fix(post-job editor): avoid draftjs mis-trigger onChange by empty str
1 parent 5f66f3d commit dfb013b

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

containers/JobEditor/logic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export const inputOnChange = (part, e) => updateEditing(store, part, e)
138138
export const bodyInputOnChange = content => {
139139
store.markState({ extractMentions: extractMentions(content) })
140140

141+
if (store.isEdit && content === '') return false
141142
// extractMentions: extractMentions(content)
142143
updateEditing(store, 'body', content)
143144
}

containers/PostEditor/logic.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ export const onMentionSearch = name => {
125125

126126
export const onMention = user => store.addReferUser(user)
127127

128-
// const loadPost = id => sr71$.query(S.post, { id })
129-
130128
const openAttachment = att => {
131129
if (store.activeThread === THREAD.RADAR) {
132130
store.updateEditing({ copyRight: 'reprint' })
@@ -136,8 +134,6 @@ const openAttachment = att => {
136134
// const { type } = att
137135
// if (type === TYPE.PREVIEW_POST_EDIT) loadPost(att.id)
138136

139-
// const { id, title, body, digest } = att
140-
141137
store.updateEditing(att)
142138
store.markState({ isEdit: true })
143139
}
@@ -152,7 +148,10 @@ export const inputOnChange = (part, e) => updateEditing(store, part, e)
152148
export const bodyInputOnChange = content => {
153149
store.markState({ extractMentions: extractMentions(content) })
154150

155-
// extractMentions: extractMentions(content)
151+
// draft.js will mis trigger onChange event with empty string.
152+
// currently this is a bug: in edit can't update to empty.
153+
if (store.isEdit && content === '') return false
154+
156155
updateEditing(store, 'body', content)
157156
}
158157

@@ -190,13 +189,6 @@ const DataSolver = [
190189
dispatchEvent(EVENT.REFRESH_POSTS)
191190
},
192191
},
193-
{
194-
match: asyncRes('post'),
195-
action: ({ post }) => {
196-
debug('before updateEditing: ', post)
197-
store.updateEditing(post)
198-
},
199-
},
200192
{
201193
match: asyncRes('searchUsers'),
202194
action: ({ searchUsers: { entries } }) => store.updateMentionList(entries),

0 commit comments

Comments
 (0)