Skip to content

Commit 1cb4c22

Browse files
fix: react-mentions inside react-new-window (#531)
Allow input to call onChange when inside a new window
1 parent 3294221 commit 1cb4c22

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/MentionsInput.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
mapPlainTextIndex,
1313
readConfigFromChildren,
1414
spliceString,
15+
isIE,
1516
isNumber,
1617
keys,
1718
omit,
@@ -471,13 +472,15 @@ class MentionsInput extends React.Component {
471472
// Handle input element's change event
472473
handleChange = (ev) => {
473474
isComposing = false
474-
// if we are inside iframe, we need to find activeElement within its contentDocument
475-
const currentDocument =
476-
(document.activeElement && document.activeElement.contentDocument) ||
477-
document
478-
if (currentDocument.activeElement !== ev.target) {
479-
// fix an IE bug (blur from empty input element with placeholder attribute trigger "input" event)
480-
return
475+
if(isIE()){
476+
// if we are inside iframe, we need to find activeElement within its contentDocument
477+
const currentDocument =
478+
(document.activeElement && document.activeElement.contentDocument) ||
479+
document
480+
if (currentDocument.activeElement !== ev.target) {
481+
// fix an IE bug (blur from empty input element with placeholder attribute trigger "input" event)
482+
return
483+
}
481484
}
482485

483486
const value = this.props.value || ''

src/utils/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export { default as spliceString } from './spliceString'
1414
export { default as makeMentionsMarkup } from './makeMentionsMarkup'
1515
export { default as iterateMentionsMarkup } from './iterateMentionsMarkup'
1616
export { default as getSubstringIndex } from './getSubstringIndex'
17+
export { default as isIE } from './isIE'
1718
export { default as isNumber } from './isNumber'
1819
export { default as merge } from './merge'
1920
export { default as omit } from './omit'

src/utils/isIE.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const isIE = () => !!document.documentMode
2+
3+
export default isIE

0 commit comments

Comments
 (0)