Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 64b51df

Browse files
Jainil Parekhfacebook-github-bot
authored andcommitted
IE could not display composer when opening or creating a new group chat from the chat create view
Summary: When opening a group chat from workplace chat's new message in IE the first invocation of interfaceselection.addRange throws an unspecified error. Remarkably, subsequent invocations work fine and draft editor is able to continue as usual. This typically happens when IE doesn't like something but it is very hard to suss out what the root cause is. So I'm wrapping with a try catch so that this does not crash the draft editor completely. Reviewed By: danielbuechele Differential Revision: D19163859 fbshipit-source-id: ded92cae390dfca8d8956a49c1be54b1540b2998
1 parent afb708f commit 64b51df

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/component/selection/setDraftEditorSelection.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ import type SelectionState from 'SelectionState';
1515

1616
const DraftEffects = require('DraftEffects');
1717
const DraftJsDebugLogging = require('DraftJsDebugLogging');
18+
const UserAgent = require('UserAgent');
1819

1920
const containsNode = require('containsNode');
2021
const getActiveElement = require('getActiveElement');
2122
const getCorrectDocumentFromNode = require('getCorrectDocumentFromNode');
2223
const invariant = require('invariant');
2324
const isElement = require('isElement');
2425

26+
const isIE = UserAgent.isBrowser('IE');
27+
2528
function getAnonymizedDOM(
2629
node: Node,
2730
getNodeLabels?: (n: Node) => Array<string>,
@@ -332,7 +335,17 @@ function addPointToSelection(
332335
DraftEffects.handleExtensionCausedError();
333336
}
334337
range.setStart(node, offset);
335-
selection.addRange(range);
338+
339+
// IE sometimes throws Unspecified Error when trying to addRange
340+
if (isIE) {
341+
try {
342+
selection.addRange(range);
343+
} catch {
344+
// ignore
345+
}
346+
} else {
347+
selection.addRange(range);
348+
}
336349
}
337350

338351
module.exports = {

0 commit comments

Comments
 (0)