Skip to content
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

dropActive bug when upload component is wrapped by other component #254

Open
fiter92 opened this issue Dec 10, 2018 · 4 comments
Open

dropActive bug when upload component is wrapped by other component #254

fiter92 opened this issue Dec 10, 2018 · 4 comments

Comments

@fiter92
Copy link

fiter92 commented Dec 10, 2018

I'm using vue-upload-component inside vue-js-modal component:

<modal name="popup">
  <file-upload ref="upload" :drag="true" ... > 
    <button>Load files</button> 
  </file-upload> 
  <div v-show="$refs.upload && $refs.upload.dropActive" class="drop-active">
    <h3>Drop files to upload</h3>
  </div> 
</modal>

When I'm opening a modal and trying to drag files - the .drop-active doesn't showing up ( but files dragging properly)
And .drop-active doesn't showing up until I have drag or upload files using a button. After that it works fine.
It happens only if vue-upload-component is inside vue-js-modal component.

@denis-markushin
Copy link

I run into the same issue. Have you found a solution?

@fiter92
Copy link
Author

fiter92 commented Jan 26, 2019

Nope =(

@onlunar
Copy link

onlunar commented Feb 12, 2019

Here's a solution:
reference:Accessing-Child-Component-Instances-amp-Child-Elements
Accessing $refs from within templates or computed propertie should be avoided as $refs are only populated after the component has been rendered, and they are not reactive.So when the modal opened,the $refs.upload is still undefined,yet accessable in the $nextTick after the next DOM update cycle.
Check the example below,using element-ui components.

<el-button @click="handleUpload">Open Dialog</el-button>
<el-dialog :visible.sync="uploadVisible" ...>
  <div v-show="uploader && uploader.dropActive" class="drop-active">
    <h3>Drop to Upload</h3>
  </div>
 <file-upload ref="upload" ...>Click Or Drop Files</file-upload>
</el-dialog>
data(){
  return {
    uploader: false
  }
},
methods:{
  handleUpload() {    
      this.uploadVisible = true;  
      // this.$refs.upload -> undefined
      this.$nextTick(() => {  
          // this.$refs.upload -> Vue Component
          this.uploader = this.$refs.upload;  
      });  
  }
}

@JoshMoreno
Copy link

For anyone who's having problems with this, see my pr #346 for workarounds until the pr gets merged

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

No branches or pull requests

4 participants