Always focus on the most relevant input of any modal (not only in the compose window)

I would like to propose to always set the cursor focus on the relevant input of modals instead of not setting it.

There’s already this PR for the input of a chat window and this should also apply to the following locations:

Redirect a message / Share a contact

Create new group

Create new channel

All apps & media - files tab

My profile / Change details of group/channel

Thank you for compiling the list. I agree with the suggestion.
The reason this is not working is technical.

In fact we already declare autofocus on some of the elements, e.g. in the Add Members dialog, but that is not working due to Bug: autoFocus broken inside <dialog /> · Issue #23301 · react/react · GitHub. React was made before we had the nice browser native <dialog> implementation which we use.

Thank you for clarifying that the cause is a technical one.

I just wondered because this modal (entering a custom name for a contact) indeed sets the focus on the input correctly:

Is it different to all the other modals?

It’s simply because it’s the first focusable element in the dialog: Chromium focuses it when the dialog gets opened. (We also have a hack to disable this “focus first element by default” behavior when the element is a button and doesn’t have autofocus on it).