browser icon indicating copy to clipboard operation
browser copied to clipboard

Browser.Dom.Focus returns an Ok on disabled element

Open Confidenceman02 opened this issue 4 years ago • 0 comments

The Story

Say we have a button in a view `button[id "SomeId"][text "Button"].

Programatically focussing on that button with a Cmd like - Task.attempt focusMsg (BrowserDom.focus "SomeId") will produce a Result that will resolve to Ok ().

This makes sense, the button is in the view with a matching id, we found that button and focused on it. Awesome!

Now say we disable the button button[id "SomeId", disabled True][text "Button"]

This button will not be able to receive focus, the DOM wont allow it and it is expected behaviour.

Lets say what the hoot, lets try and focus on it anyway, so we do - Task.attempt focusMsg (BrowserDom.focus "SomeId")

Interestingly the Result resolves to Ok (). But wait.. the button cannot receive focus, nor did it in the view..

It seems the 'Ok ()' has more to do with the fact the element was found, not that it received focus which to me seems like an opportunity.

Whilst I understand the DOM's focus does not give us feedback that something was indeed successfully focused I believe it could be implemented and provide a pretty sweet guarantee.

Confidenceman02 avatar Mar 27 '20 07:03 Confidenceman02