You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 1, 2021. It is now read-only.
When mounting a new Binder component, we sometimes want it to be focused on a specific element on initialization.
We tried to use the componentDidMount lifecycle method of the parent component, with a activeBinder(binderId, desiredEltId) but this doesn't seem to be working.
It appears that the activeBinder function will call computeResetBinder and this function will perform a check on the length of the children elements array length.
And this length is initialized at empty array, as can be seen in the buildBinderFromProps function.
Shouldn't the elements be filled with props.children in the buildBinderFromProps function ?
So that the activeBinder function would actually activate it on the specified element ?
Right now, we have to either do this in a setTimeout(..., 0) as it is done in the componentDidMount function of the Binder component.
i.e :
componentDidMount(){/* Workaround to make the desiredId focused by default */window.setTimeout(()=>activeBinder(binderId,desiredId););}
A less hacky way we found is to do it in the componentDidUpdate function, by first checking if the binder has a selectedId.
i.e :
componentDidUpdate(){if(!this.props.selectedId){activeBinder(binderId,desiredId);}}// SelectedId is coming from the Binder's storeconnect(()=>({selectedId: getCurrentSelectedId()(),}))(MyComponent);
So what is the best way to handle this ?
Bonus question : could it be possible to give the desiredElementId to focus as an inline react props ?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When mounting a new Binder component, we sometimes want it to be focused on a specific element on initialization.
We tried to use the componentDidMount lifecycle method of the parent component, with a
activeBinder(binderId, desiredEltId)
but this doesn't seem to be working.It appears that the activeBinder function will call
computeResetBinder
and this function will perform a check on the length of the children elements array length.And this length is initialized at empty array, as can be seen in the
buildBinderFromProps
function.Shouldn't the elements be filled with props.children in the
buildBinderFromProps
function ?So that the activeBinder function would actually activate it on the specified element ?
Right now, we have to either do this in a
setTimeout(..., 0)
as it is done in thecomponentDidMount
function of the Binder component.i.e :
A less hacky way we found is to do it in the
componentDidUpdate
function, by first checking if the binder has a selectedId.i.e :
So what is the best way to handle this ?
Bonus question : could it be possible to give the desiredElementId to focus as an inline react props ?
The text was updated successfully, but these errors were encountered: