When the modal opens, I want to set focus on the input. The modal visibility is controlled in the class list logic, so I added a Focus On Component block and get the component by Id.
I think setting the focus in the Class List Logic handler is too soon as the modal is not visible at that point. I’d use the Visibility Logic for that.
Do you mind explaining what you’re thinking? I don’t see how putting the focus on component in the visibility logic block solves the modal not being visible. Doesn’t the visibility block control the visibility, not when it becomes visible?
Is the problem with the visibility or setting the focus?
If the latter, the focus cannot be set unless the component is visible. The class list logic handler has logic to make it visible. This means the focus setting logic must be somewhere where you know it runs after the component became visible.
I hope you and the entire backendless team had a happy holiday! The issue is setting focus. Would you be able to suggest where to place the set focus code? I’m unsure how I would know when the component has become visible.
To make the autofocus set in the component settings work, you need to use Visibility Logic, as Mark wrote above.
Or you can add a small delay before the focus is set:
I got the focus to set on click by adding the delay as you suggested. Thanks for that; however, I want to be able to open the modal and set the focus whenever the corresponding page data value changes. As it is opened more than one way.
Can you provide an example of how to use Visibility Logic? I tried a few things and had no luck.
I’m not having trouble with visibility; I’m having trouble with setting the focus. I used the modal tutorial (How To Create A Modal In UI Builder | Backendless) and can get the modal with the input to appear and disappear just fine. I need the input on the modal to grab focus when the modal is made visible.