feat(*): add way to get ref to focuable components#218
feat(*): add way to get ref to focuable components#218eddywashere merged 1 commit intoreactstrap:masterfrom
Conversation
|
Could you add lodash noop as the default prop. |
|
They default to |
|
@TheSharpieOne I agree that refs could be used to set focus on an input element but wouldn't it be more straight forward by accepting a focus(or autoFocus) attribute for focus alone? We could also have a getRef attribute that will return the underlying input element's ref and can be used independently. Its more of getting the element ref and focusing it vs setting the attribute of element and make itself focus. |
|
@TheSharpieOne great point. I didn't think about that. 👍 @ajainarayanan good discussion, moving this to #172 since it's out of scope for this pr. |
#216) * add NavbarToggler example * feat(Collapse): add Collapse component #79 (#201) * init collapse * add collapse animation * add margin between toggle button and collapse * disable lint on force refresh DOM line. * add test to Collapse * remove height after shown * Revert "remove height after shown" This reverts commit eff9353. * remove height after shown. * add more test * use setState() to set inline height style * remove custom tag in doc * add inline style test * remove comment * set height to null when isOpen is true * add initial state test * chore(release): adding 3.8.0 (#217) * chore(release): adding 3.8.0 * feat(Collapse): add cssModule support * feat(refs): add getRef to focusable components (#218) * chore(release): adding 3.8.1 (#219) * add NavbarToggler example * update example to use Collapse component
The main use-case for refs is the ability to set focus on an element, because of this, I have added the ability to get a ref to components which generate focusable items (inputs, buttons, links/anchor).
I just want to note, using a ref to get an input's value is not the correct way. Using a callback, such
onChangeoronBlur, you can use the supplied event to get the value without needing a ref.