combobox retains focus after onDataChange method with dialog

If my onDataChange method includes a dialog (requiring user response), a “return true” is not sufficient to force the cursor to leave the field.
The valuelist remains active/with drop-down list visible.

If there’s no dialog, the drop-down list does disappear (as desired) - provided I include a “return true” step.

a combobox only looses focus (and closes the drop down) when the ondatachange call returns.
If you show a modal dialog in the ondatachange then you block the call and it will not return so it will not loose the focus.

How do you force it to loose focus … as this is rather confusing for the user?
Requesting focus on another field works, but is rather artificial.

problem is that it is probably the focus lost even that trigger the datachange.
So it is in the process of loosing focus. the only thing is that you block it …
What do you exactly do in the that dialog? Does the result have any influence of that you return the the datachange?
If that is not the case then i guess what you also could do is use the scheduler plugin to schedule a event (1 mil second in the future) that calls the show dialog code.
Else i guess focusing a button or something (that could be really small 1by1 pixel) could also help

The dialog = to inform the user that an action (datachange) is not allowed.
I then revert the datachange - restoring the oldValue - and then exit the method.

Here is some sample code:

function FIELD_onDataChange(oldValue, newValue, event) {

if(utils.hasRecords(relationship_name)) {
var vMessage = ‘This action is not allowed because …’
var vAnsw = plugins.dialogs.showQuestionDialog( ‘i18n:STB.dialog.warning’, vMessage, ‘OK’)
field = oldValue
databaseManager.saveData()
return true
}

REST OF METHOD …

so it is not really a question dialog that you show, it is just a warning dialog or an information dialog (the user has no choice)

so you could do something like:

if(utils.hasRecords(relationship_name)) {
var vMessage = ‘This action is not allowed because …’
plugins.scheduler.addJob(“showdialog”,new Date(), showDialog);
field = oldValue
databaseManager.saveData()
return true
}

function showDialog()
{
plugins.dialogs.showQuestionDialog( ‘i18n:STB.dialog.warning’, vMessage, ‘OK’)
}

Sometimes there is a dialog requiring user response (yes/no for example).
No → abort
Yes → continue

yes then my solution is not doable, then the only other way is if that works is calling request focus on something else.

I much prefer using onDataChange than creating a button with a function (which gives more control, but clutters the user interface).
But as we’ve seen, it will only works to a point.

Any chance of giving us more options (in the future), so we don’t have to resort to workarounds?

I have found an effective way around this issue. Using application.updateUI(‘’)

Here is my code:

if(utils.hasRecords(relationship_name)) {
field = oldValue
databaseManager.saveData()
var vMessage = ‘Message’
var vAnsw = plugins.dialogs.showQuestionDialog( ‘i18n:STB.dialog.warning’, vMessage, ‘OK’)
application.updateUI(‘’)
return true
}
REST OF METHOD

then i would say that you first call updateUI() before showing the dialog…