2

I am facing the issue with :

I am using a lookup with lightning: input. When the user clicks enter search text in this input field. New component opens up showing related search records.

Now to close search window, I have a cross button in front of the field.

The user wants that on clicking anywhere outside search result component/box. This component should get closed. Now I am unable to find any workaround of attribute keyUp which we use in ui:input. Any idea how to achieve that.

enter image description here

3
  • 1
    have you tried wrapping your input in a div tag with the keyup attribute? I recall lightning:input not fully supporting this, hence the wrapping in a div (or any other html tag that supports onkeyup
    – glls
    Commented Mar 19, 2018 at 12:58
  • It sounds like you actually want onblur, not onkeyup? That will tell you when they've clicked outside of the lightning:input
    – Aidan
    Commented Mar 19, 2018 at 14:40
  • Thanks for suggestions! but the issue is as you can see this is a Multi check box. So when I click on a single checkbox, onblur gets called and dropdown goes off. I want, it should not go off when clicked within this component. it should go when clicked outside only. Please suggest. Commented Mar 19, 2018 at 17:13

1 Answer 1

1

You can add the keyup to and input field, you just have to specify UpdateOn so that the change event triggers on keyup

<ui:inputText aura:id="searchInput" 
    label="Search" 
    keyup="{!c.performSearch}" 
    updateOn="keyup" />

Source

Edit: I'm pretty sure this will work on a lightning:input as well, but I haven't tested that.

2
  • I don't see updateOn documented in e.g. lightning:input (Beta).
    – Keith C
    Commented Mar 19, 2018 at 16:02
  • unfortunately, the attribute is not available on lightning: input Commented Mar 19, 2018 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .