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

use <sui-popup hoverable> with v-for got getBoundingClientRect' of undefined" when chanage hover compnent #496

Open
ladudu opened this issue May 24, 2021 · 5 comments

Comments

@ladudu
Copy link

ladudu commented May 24, 2021

I'm submitting a bug report
Do you want to request a feature or report a bug?
I want to report a bug
What is the current behavior?
I use got error with [TypeError: Cannot read property 'getBoundingClientRect' of undefined], when i change hover on the trigger slot.

Please tell us about your environment:

semantic-ui-vue: 0.11.0
semantic-ui-css: 2.4.1
Browser: [ Chrome 89.0.4389.114]
Language: [ vue-cli default config ]

<template>
  <div>
    <sui-popup v-for="user in users"  hoverable :key="user">
      <h1 slot="trigger">{{user}}</h1>
      <sui-popup-content >
        <h1>hi,i'm {{user}}</h1>
      </sui-popup-content>
    </sui-popup>
  </div>
</template>

<script>
export default {
  data: function () {
    return {
      users: ['bob',"tom"]
    }
  }
};
</script>

@ladudu ladudu changed the title use popup[hoverable] with v-for got getBoundingClientRect' of undefined" when chanage hover compnent use <sui-popup hoverable> with v-for got getBoundingClientRect' of undefined" when chanage hover compnent May 24, 2021
@ladudu
Copy link
Author

ladudu commented May 24, 2021

image

@ladudu
Copy link
Author

ladudu commented May 25, 2021

I found reason with the problem.
when have two sui-popup(like A,B)
Trigger A but not hover on the A.
immediately,Trigger B(time < HOVERABLE_BLUR_DELAY),
There are two PopupContainer at the same time,
ref only allowed one value ,
A set ref value is container,
B didn't set the some value.
so,I got the error.

@ladudu
Copy link
Author

ladudu commented May 25, 2021

I solved the problem.like this,

      <portal to="semantic-ui-vue">
        <div
          ref={"container"+this.id}
          class={className}
          style={this.mountedStyle}
          onMouseover={() => this.$emit('mouseover')}
          onMouseleave={() => this.$emit('mouseleave')}
        >
          {this.$slots.default}
        </div>
      </portal>
  mounted() {
    this.$nextTick(() => {
      this.popupCoords =  this.$refs['container'+this.id].getBoundingClientRect();
      this.setPopupStyle();
    });
  },

But Code is not particularly

@Fredemb
Copy link

Fredemb commented Sep 21, 2021

Could you please elaborate your solution, maybe even into a small working example? 😎

I have the same problem, but I'm struggling to understand your solution 😢

@ladudu
Copy link
Author

ladudu commented Sep 22, 2021

vue ref property has unique name,All popup component share one id.when the first use popup ,the second can't use the id.so the error occurs.

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

2 participants