Keyboard Shortcut Widget -> enter on input field shows up empty in microflow

3
I have almost the exact same issue as described here: https://community.mendix.com/link/questions/88559  I use an input field in a dataview and have a microflow button that calls a microflow with a parameter of this datafield. When I type, leave the input field and then hit enter, there's no issue. However when I write something and immediately hit enter, the attribute shows an empty string in the microflow. When I write something, leave the input field, change it to something different and then hit enter, it will show the message I wrote the first time. In other words: it only passes on the string if I left the input field. It doesn't work with a committed object, it doesn't work when the widget is in a different container, it doesn't work if the dataview is standalone and the object is passed on to the page first (instead of created in a datasource microflow). The modeler version is 7.17 by the way, wasn't able to select that yet. Any idea what it might be?
asked
2 answers
5

Hello Sytze,

I created a test project and was able to recreate your issue. I solved it using the following JavaScript (with jQuery) snippet:

$(".container-msginput").keypress(function(event){
   var key = (event.keyCode ? event.keyCode : event.which);
   if(key == '13'){
      var temp = document.createElement("input");
      document.body.appendChild(temp);
      temp.focus();
      document.body.removeChild(temp);
      $(".btn-sendmessage").click();
      $(".input-message")[0].firstChild.focus();
   }
});

 

I tried to use the blur() method, then refocusing using the focus() method, yet this did not work for me.

I solved the issue by creating a temp input field to which I change the focus, then removing the temp input field, followed by the execution of the microflow using the click() method, lastly refocusing the initial text message field.

I hope that this helps! :-)

 

*Edit* Grammar corrections.

answered
1

Hello Sytze,

Microflows use the view object as an input, which gets held in your cache. I would have expected your object to be updated per key type (with the onchange event) but this doesn't seem the case and the entity appears to be updated on an focusout event. 

If you need to be able to hit enter and trigger the behaviour immediately you can try ticking your "Abort on Validation errors" option in your button's microflow settings - this might force an update from the attribute fields. You can also try a field required validation on the field and see if it makes a difference. 

The only other alternative I can see is creating your own field or button through either your own custom widget or added through the HTMLSnippet widget.

answered