Skip to content

[v2.2.0-beta.1] cannot access $refs in transition enter hook #4998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sqal opened this issue Feb 24, 2017 · 3 comments
Closed

[v2.2.0-beta.1] cannot access $refs in transition enter hook #4998

sqal opened this issue Feb 24, 2017 · 3 comments

Comments

@sqal
Copy link
Contributor

sqal commented Feb 24, 2017

Vue.js version

v2.2.0-beta.1

Reproduction Link

2.2.0-beta.1 with bug(?) - https://jsfiddle.net/sqal/6xug3huc/1/
2.1.10 working repo - https://jsfiddle.net/sqal/hx0cb267/1/

Steps to reproduce

  1. Click on the 'show' button to open the menu. In console you should see this error:
    Cannot read property 'updateScroll' of undefined. It happens because $refs object is empty at this time.
  2. But.. when we replace @Enter hook with @after-enter, then everything works again and we have access to the $refs

And one more important thing. This bug occurs only when we use v-show to control visibility of the element. If we replace v-show with v-if, then this bug no longer happens.

What is Expected?

I expect to have access to component's $refs inside transition @Enter hook.

What is actually happening?

$refs object is empty when I try to access it inside @Enter hook.

@yyx990803
Copy link
Member

Closed by reverting the ref callback changes. I think we'll just drop the feature because it's difficult to implement it without breaking backwards compat.

@kindy
Copy link

kindy commented Sep 12, 2017

@yyx990803
Some time we want to be notify if some component is rendered, the callback ref is very useful in those cases, else we need to implement events 'inited' in mounted for all components we want to monitor.

For the fail in this case, I think it's caused by resetRefs.
do we have any plan to get callback ref back? or can I give any help on this?

@tangjinzhou
Copy link

@kindy
Maybe we can use directive to implement ref callback function.
I published a plugin vue-ref, you can try it.
I used it in ant-design-vue and found no problems for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants