From ee063923a7cf9b191b7cfbecb404e16f1dedb8f7 Mon Sep 17 00:00:00 2001 From: Sargis Dudaklyan Date: Sun, 11 Dec 2022 22:22:27 -0800 Subject: [PATCH] Bug Fix: https://github.com/signavio/react-mentions/issues/634 --- src/utils/iterateMentionsMarkup.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/iterateMentionsMarkup.js b/src/utils/iterateMentionsMarkup.js index 914e35f2..ba83d678 100644 --- a/src/utils/iterateMentionsMarkup.js +++ b/src/utils/iterateMentionsMarkup.js @@ -16,9 +16,13 @@ const iterateMentionsMarkup = ( let accOffset = 2 // first is whole match, second is the for the capturing group of first regexp component const captureGroupOffsets = config.map(({ markup }) => { - const result = accOffset // + 1 is for the capturing group we add around each regexp component in combineRegExps - accOffset += countPlaceholders(markup) + 1 + let result + if (markup !== undefined) { + result = accOffset + accOffset += countPlaceholders(markup) + 1 + return result + } return result })