I have a lightning:input
and when the focus is on it and you type the enter stroke: it refreshes the page.
I tried to prevent it by implementing the onchange
: avoid the event to be fire but the callback is never launched.
Component.cmp:
<lightning:input
type="email"
onchange="{! c.callbackNeverCalled }"
/>
Controller.js:
callbackNeverCalled: function(component, event, helper) {
event.preventDefault(); // Does not prevent from refreshing/redirecting the page & also 'deprecated'.
event.getSource().getParams();
// Is an empty object but the good way to do (cf. documentation)
}
Best Answer
Thanks to SFDCFOX and PatMcClellan__c. Workaround is: