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

MergeTags dropdown doesn't close on removing @ #23

Open
vinay0x opened this issue Nov 3, 2019 · 3 comments
Open

MergeTags dropdown doesn't close on removing @ #23

vinay0x opened this issue Nov 3, 2019 · 3 comments

Comments

@vinay0x
Copy link

vinay0x commented Nov 3, 2019

If I type '@' the dropdown appears, and if I remove the '@', the dropdown is still there.

@dstpierre
Copy link
Collaborator

Yes good catch, the popup should also dismiss if we press the Escape key.

@vinay0x
Copy link
Author

vinay0x commented Nov 22, 2019

@dstpierre That's true. Let me know if you need any help with this.

@dstpierre
Copy link
Collaborator

@vinay0x sure feel free to fork and try to implement this if you want. This would be in src/react-trix.tsx at line: 125:

// if we have a collapse selection
    if (text && range[0] == range[1]) {
      // if we have a merge tag mergeTagTrigger
      if (props.mergeTags) {
        // get the cursor position and compare the last character with our mergeTagTrigger
        const lastChar = range[0] - 1;
        if (lastChar >= 0 && lastChar < text.length) {
          const trigger = text[lastChar];
          for (let i = 0; i < props.mergeTags.length; i++) {
            if (trigger == props.mergeTags[i].trigger) {
              state.showMergeTags = true;
              state.tags = props.mergeTags[i].tags;
              this.setState(state);
              break;
            }
          }
        }
      }
    }

I would try to see if state.showMergeTags is already true and there's no trigger character anymore.

For the escape key, a new keypress event could be added setting the showMergeTags to false and that should be enough for that part.

Let me know how it goes.

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

No branches or pull requests

2 participants