Skip to content

Browser.Dom.Focus returns an Ok on disabled element #106

Open
@Confidenceman02

Description

@Confidenceman02

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions