question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Function wiring breaks for components that show/hide slot content using v-if

See original GitHub issue

Vue.js version

2.0.0-rc.3

Reproduction Link

http://codepen.io/analog-nico/pen/dXBRBG

Steps to reproduce

  1. Click the link “Open popup using v-if”
  2. A badly designed popup opens
  3. Click the “Close” link
  4. For this first time the popup closes successfully
  5. Click the link “Open popup using v-if” again
  6. The popup opens again
  7. Click the “Close” link

What is Expected?

  • Again, the popup closes successfully

What is actually happening?

  • Vue fails to call an internal function that got missing.
  • The closePopupUsingVIf function attached to the “Close” link’s click event never gets called.
  • The popup does not close.

For reference the codepen contains the exact same implementation of the popup with the only difference that it uses v-show instead of v-if to show/hide the popup. v-show works perfectly.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusBorgcommented, Aug 25, 2016

Using $refs for this won’t work, as explained by @fnlctrl due to issue #3455, but I would say this is not a recommended pattern anyway.

I would rather: a) pass a is-shown prop to the component, (https://jsfiddle.net/Linusborg/rwa5cfdm/) or b) use v-if on the component itself (https://jsfiddle.net/Linusborg/rwa5cfdm/1/)

if the popup component will have its own controls, i.e. a close button, $emit() an event from it and let the parent listen with @event="handler" on the component - then the parent can change the state value.

This has several advantages:

  • the parent knows about weither or not the popup is shown
  • We don’t need to use tight coupling to the child components via $ref in you JS code.
  • the parent stays in control of when to actually show and hide the popup.
0reactions
analog-nicocommented, Aug 26, 2016

@prog-rajkamal That is a valid point which @fnlctrl also mentioned in his first response. However, the bug still occurs if I move v-if to a child div. See my updated codepen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function wiring breaks for components that show/hide slot ...
URL Extension Required. When linking another Pen as a resource, make sure you use a URL Extension of the type of code you...
Read more >
Untitled
#il Welded wire fence panels toronto, Australian postie bike for sale, Enfermedades repentinas, Oflu kadir, Aloha marketing international?
Read more >
Untitled
93 ford explorer radio wiring diagram, Aldea global concepto pdf, Busby british ... Toledo public library harvest, Adilene idalie break up with luis, ......
Read more >
liquid-fire - UNPKG
isArray) {\n _isArray = function (x) {\n return Object.prototype. ... */\r\n/* Browser support: Using this shim instead of jQuery proper removes support for ......
Read more >
Democracy Suite Use Procedures - Verified Voting
Table of Contents ... 4.5 Logic and Accuracy Testing of System and Components . ... each having a different role in the period...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found