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

Commit

Permalink
IE could not display composer when opening or creating a new group ch…
Browse files Browse the repository at this point in the history
…at 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
  • Loading branch information
Jainil Parekh authored and facebook-github-bot committed Dec 19, 2019
1 parent afb708f commit 64b51df
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/component/selection/setDraftEditorSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ import type SelectionState from 'SelectionState';

const DraftEffects = require('DraftEffects');
const DraftJsDebugLogging = require('DraftJsDebugLogging');
const UserAgent = require('UserAgent');

const containsNode = require('containsNode');
const getActiveElement = require('getActiveElement');
const getCorrectDocumentFromNode = require('getCorrectDocumentFromNode');
const invariant = require('invariant');
const isElement = require('isElement');

const isIE = UserAgent.isBrowser('IE');

function getAnonymizedDOM(
node: Node,
getNodeLabels?: (n: Node) => Array<string>,
Expand Down Expand Up @@ -332,7 +335,17 @@ function addPointToSelection(
DraftEffects.handleExtensionCausedError();
}
range.setStart(node, offset);
selection.addRange(range);

// IE sometimes throws Unspecified Error when trying to addRange
if (isIE) {
try {
selection.addRange(range);
} catch {
// ignore
}
} else {
selection.addRange(range);
}
}

module.exports = {
Expand Down

0 comments on commit 64b51df

Please sign in to comment.