jeff-collins/ment.io

BUG: Menu triggered even after an item is selected

shyamal890 opened this issue · 6 comments

Menu is triggered after a menu item is selected. Try the example in PLUNKER

In Chrome: (Once you select an item, press Shift+Enter)
error chrome

In Firefox: (Once you select an item, try pressing spacebar)
error firefox

I have the same issue. But not when I select using mouse cursor. If I use arrow and enter button in keyboard to select the particular item from the list.
untitled

@shyamprasathbrigita Try putting up a GIF (Use LICEcap) as it is not clear.

I hope @jeff-collins will have a look sometime soon.

Thanks you for your support.

As I am using Ubuntu OS I could create that GIF file. But the matter is very simple. It is exactly as what happened to you. But not when select the item using mouse cursor. It occurs only when I use enter button to select the item.

It would be great If I get the solution ASAP.

If possible I look for other tools to create the GIF.

I am having the same issue but with Mozilla Firefox only. (46.0.1). Here i select one menu, it is ok, but when i go and type another @ it shows previous one

@shyamal890

I just used the plugin and had the same issue. I found the issue and fixed the same.

Please find the below code

function getTextPrecedingCurrentSelection (ctx) {
var text;
if (selectedElementIsTextAreaOrInput(ctx)) {
var textComponent = getDocument(ctx).activeElement;
var startPos = textComponent.selectionStart;
text = textComponent.value.substring(0, startPos);

        } else {
            var selectedElem = getWindowSelection(ctx).anchorNode;
            if (selectedElem != null) {
                var workingNodeContent = selectedElem.textContent;
				
                var selectStartOffset = workingNodeContent.length;
				console.info(selectStartOffset);
                if (selectStartOffset >= 0) {
                    text = workingNodeContent.substring(0, selectStartOffset);
                }
            }
        }
						
        return text;
    }

Replace it with the below code.

    function getTextPrecedingCurrentSelection (ctx) {
        var text;
        if (selectedElementIsTextAreaOrInput(ctx)) {
            var textComponent = getDocument(ctx).activeElement;
            var startPos = textComponent.selectionStart;
            text = textComponent.value.substring(0, startPos);

        } else {
            var selectedElem = getWindowSelection(ctx).anchorNode;
            if (selectedElem != null) {
                var workingNodeContent = selectedElem.textContent;
                var selectStartOffset = workingNodeContent.length;
                if (selectStartOffset >= 0) {
                    text = workingNodeContent.substring(0, selectStartOffset);
                }
            }
        }
        return text;
    }

@vihari1991
I have just checked both code snippets are same only console.info removed from your code. please check it once.