Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production build cannot select mention #634

Open
SargisPlusPlus opened this issue Dec 12, 2022 · 7 comments
Open

Production build cannot select mention #634

SargisPlusPlus opened this issue Dec 12, 2022 · 7 comments

Comments

@SargisPlusPlus
Copy link

SargisPlusPlus commented Dec 12, 2022

Steps to reproduce:

Cannot reproduce it. Only happens in production.

Expected behaviour:

Observed behaviour:
I can see a list of mentions when I start typing "@" but choosing the mention, it does not choose it.
When running in dev mode, it works as expected, no issues.
In console log, I see:

Uncaught TypeError: Cannot read properties of undefined (reading 'markup')
    at tt (react-mentions.esm.js:98:1)
    at tu (react-mentions.esm.js:267:1)
    at v.addMention (react-mentions.esm.js:1822:1)
    at v.selectFocused (react-mentions.esm.js:1525:1)
    at react-mentions.esm.js:1480:1
    at Object.eA (react-dom.production.min.js:55:313)
    at eq (react-dom.production.min.js:55:465)
    at react-dom.production.min.js:56:34
    at rg (react-dom.production.min.js:56:135)

Tech Stack:

  1. react-mentions": "^4.4.7"
  2. "react": "^18.2.0",
  3. "react-dom": "^18.2.0"
  4. "next-js": "12.3.1"

My code:

            <MentionsInput
              style={mentionsInputStyle}
              value={message}
              onChange={(e) => setMessage(e.target.value)}
              placeholder={'Add a comment or mention with @'}
              a11ySuggestionsListLabel={'Suggested mentions'}
            >
              <Mention
                data={(teamMembers || []).map(member => {
                  const item = { id: member.id, display: `${member.first_name} ${member.last_name}` };
                  console.log("Mentions - item", item);
                  return item;
                })}
                trigger="@"
                style={mentionStyle}
              />
            </MentionsInput>

I was able to inject a breakpoint right before the issue happens(it breaks on line 103). If you look at the image, I am puzzled why captureGroupOffsets=5. (is this right?) Also, notice that markup, on line 81, is undefined, while it is present in the "config" (this is a single item array with object that has markup).. It is as if it iterates over config multiple times...?

Screen Shot 2022-12-11 at 9 01 15 PM

Workaround:

Not sure why but this workaround works

  var captureGroupOffsets = config.map(function (_ref) {
    var markup = _ref.markup;
    var result;

    if (markup !== undefined) {
      result = accOffset;
      accOffset += countPlaceholders(markup) + 1;
      return result;
    }

    return result;
  });

@tballenger
Copy link

+1

SargisPlusPlus added a commit to SynthesizeTech/react-mentions that referenced this issue Dec 12, 2022
SargisPlusPlus added a commit to SynthesizeTech/react-mentions that referenced this issue Dec 12, 2022
@claritycodeweb
Copy link

+1

JakeHedman added a commit to JakeHedman/react-mentions-continued that referenced this issue Feb 27, 2023
@TranLuongNam
Copy link

I also have problem like this
"react": "18.2.0",
"next": "12.3.1",
"react-dom": "18.2.0",
"react-mentions": "^4.4.10"
The issue occur when i click the mention name, see the error like image below
image

@cyrilzaharchenko
Copy link

Same issue here. Any suggestions on how to solve this?

@AayushMathur7
Copy link

+1

1 similar comment
@petrikkachur
Copy link

+1

@sosegon
Copy link

sosegon commented Apr 11, 2024

Please, see this possible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants