React-md: `Dialog` should have an `initialFocus` prop listed in the docs to be passed onto `FocusContainer`

Created on 10 May 2017  路  6Comments  路  Source: mlaursen/react-md

Description

I came across this when closing one dialog and after an async action triggered with onHide. After the async action returns successfully, I display a second dialog confirming success.

On displaying the second dialog, a warning Uncaught Error: You specified that theFocusContainershould focus an element on mount, but a focusable element was not found in the children. This could be because theinitialFocusprop is an invalid id or query selector, or the children do not contain a valid focusable element.undefined is displayed.

I fixed this by passing an initialFocus prop with an id to Dialog and it works fine, but this seems to be undocumented in the docs.

Version

  • React 15.4.2
  • React-MD 1.0.6

Most helpful comment

You can update your dialog to have focusOnMount={false} and it won't do any of the focusing logic.

All 6 comments

I have the same error. You have an example of assigning an INITIALFOCUS, please

@Edgargmc Hey Edgar, sorry for the late reply. It's literally just adding an initialFocus prop with the id of whatever element you want to focus on.

<Dialog
  initialFocus="some-element-id"
/>

It's also unnecessary. I have a dialog that doesn't have any inputs, only text. Ideally, I shouldn't need to have to use initialFocus at all. Can we fix this?

You can update your dialog to have focusOnMount={false} and it won't do any of the focusing logic.

Thanks 鉂わ笍

yeah, the focusing logic was slowing down my dialog by a lot. mine also just had text, thanks for bringing that up.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frol picture frol  路  3Comments

dandv picture dandv  路  9Comments

8bitjoey picture 8bitjoey  路  10Comments

aleksanderd picture aleksanderd  路  7Comments

MrXyfir picture MrXyfir  路  6Comments