Semantic-ui: [Modal] Attempt to focus on the first visible input when a modal is shown

Created on 5 May 2014  路  11Comments  路  Source: Semantic-Org/Semantic-UI

Forms are commonly shown within modals. Having the modal plugin search for the first visible input and focusing on it if it is found would be very convenient. To prevent breaking usability, it should store the current document.activeElement just before the modal is shown and restore focus to it when the modal closes.

Enhancement

Most helpful comment

There should be a way to disable this feature, not everyone wants their form to be submitted accidentally

All 11 comments

This makes sense as an enhancement.

You can emulate this behavior quite easily using onShow callback however, if you want this now.

This enhancement is added in pull request #836

There should be a way to disable this feature, not everyone wants their form to be submitted accidentally

Sure

@varemenos In my PR for this feature, I added a setting called "autofocus" that you could set to false in order to disable it. I'm not sure if it transitioned into the newer releases, since I don't see it in the docs anymore.

:+1: Could use the autofocus=false option.

Actually, @varemenos, this already works perfectly with autofocus: false. However, it is not in the docs currently. See PR #836

However, it is not in the docs currently

If it's not in the docs, it's not accessible...

I sound like an asshole but please understand my reasoning.

Perfectly reasonable. Just letting you know what I found. I ran into the same problem but checked the code and found it when I saw @ShimShamSam's reply.

Regardless, I already submitted a pull-request fix for the docs, Semantic-Org/Semantic-UI-Docs#34 - should be fixed soon.

Pull request was accepted and is now live. This is now in the docs.

Thanks @abernix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mixerp picture mixerp  路  3Comments

arj-196 picture arj-196  路  3Comments

mllamazares picture mllamazares  路  3Comments

deneuxa picture deneuxa  路  3Comments

miguelmota picture miguelmota  路  3Comments