Skip to content

@ inserted via open() is immediately removed when typing #45

@Azerothwav

Description

@Azerothwav

Hi,

While using the lib i encountered an issue with the open() method.

When calling mentionsComp.open() programmatically (for example, via a button click to insert @ at the cursor position), the @ is inserted into the textarea, and the mentions list opens correctly. However, as soon as I type any character after the @, the library removes the @ automatically (the online demo have the same issue).

It seems that the library only considers a mention started when the user physically types the triggerChar, and open() does not mark the mention as “active” internally. Because of this, programmatically inserting @ and opening the mentions list does not work correctly.

Expected behavior:

  • Calling open() should insert @ and keep it in the textarea.
  • The mention list should stay open and accept typed characters after the inserted @.

Current behavior:

  • @ appears when open() is called.
  • The @ disappears immediately when typing the next character or selecting a item.

Steps to reproduce:

  1. Add a button that calls mentionsComp.open().
  2. Click the button to insert @.
  3. Type a character after the @ or select a item.
  4. Observe that the @ disappears.

Environment:

  • ng-mentions version: latest version
  • Angular version: 17

Possible solution:

  • Allow open() to accept a parameter marking the mention as active, so that the library does not remove the inserted @.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions