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

A problem when i Enter keypress after i write an invalid matche #371

Open
joaolavoier opened this issue Jan 13, 2016 · 7 comments
Open

A problem when i Enter keypress after i write an invalid matche #371

joaolavoier opened this issue Jan 13, 2016 · 7 comments

Comments

@joaolavoier
Copy link

When i write an invalid matche and i type Enter key, and after this i try to write again there is an issue. I think that the Atwho lib is not removing the selection of the before node. This is happening on the contenteditable.

@joaolavoier joaolavoier changed the title Enter key when i write an invalid matche A problem when i Enter keypress when i write an invalid matche Jan 13, 2016
@joaolavoier joaolavoier changed the title A problem when i Enter keypress when i write an invalid matche A problem when i Enter keypress after i write an invalid matche Jan 13, 2016
@patrinhani-ciandt
Copy link

👍

@ichord
Copy link
Owner

ichord commented Feb 21, 2016

What is the issue?
Please give me a demo.

@JeanCarriere
Copy link

👍
Similarly, if you have the option highlightFirst: false, and you begin a match then hit ENTER, the span atwho-query is note removed and causes bugs when you write again.

@joaolavoier
Copy link
Author

@ichord Do you understand?
I resolve this issue not allowing type ENTER into a highlight, but its not a good practice.

@hendry91
Copy link

Hi, I having the same problem, any solution?

@hendry91
Copy link

hi @joaolavoier,
May I know how u add the code for not allowing type ENTER into a highlight?
I having the similiar problem,
eg: I got data "test", when I :

  1. type #test1
  2. ENTER
  3. type g
  4. my result become

#test1g

instead of

#test1
g

@joaolavoier
Copy link
Author

joaolavoier commented Jun 10, 2016

Off course @hendry91,

But im using the rangy lib to work with the node in contenteditable.

Follow some methods that i create to do it.

constructor() {
    this.contentEditor.on("keydown", this.onKeyDownEditor)
}

getElementNodeSelected(){
    let sel = rangy.getSelection();
    let rangeSelection = sel.getRangeAt(0);
    return rangeSelection.commonAncestorContainer.parentNode;
}

isHighLightNode(node){
    return node.tagName === 'SPAN' ? true : false;
}

onKeyDownEditor(event){
    let keyCode = event.keyCode;
    let selectedNode = this.getElementNodeSelected();

    if (keyCode === 13) {
        if (this.isHighLightNode(selectedNode)){
            event.preventDefault();
        }
    }
}

But its not a good practice. 😞

The better idea should be, the At.js lib remove the highlight if the match is not a real tag.

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

No branches or pull requests

5 participants