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

Wrong initialisation #42

Closed
albmat opened this issue Apr 6, 2022 · 9 comments
Closed

Wrong initialisation #42

albmat opened this issue Apr 6, 2022 · 9 comments
Labels
bug Something isn't working help wanted Extra attention is needed question A valid question

Comments

@albmat
Copy link

albmat commented Apr 6, 2022

Describe the bug
When the component is initialised, it is not always displayed correctly. The image, the canvas, the map component and the areas are always there, but sometimes neither the div#img-mapper container nor the canvas has any height, so the areas are not displayed, it is as if they were not there. You have to refresh the page to make it work correctly.

Expected behavior
The component should initialise correctly from the beginning, without the need to refresh the page.

Screenshots
Bug
Bug 1

Additional context
As you can see in the image, the component is placed inside a container with a grey background, as the content has no height, the coloured container has no height either. Although the image is visible.

@NishargShah
Copy link
Member

Can you provide me a problem example in codesandbox?

@albmat
Copy link
Author

albmat commented Apr 7, 2022

I'll try, but you can see that behaviour in the live Storybook example as well. https://img-mapper.github.io/react-docs/?path=/story/examples-simple--simple

@KeithHubert
Copy link

KeithHubert commented Apr 15, 2022

Screen Shot 2022-04-15 at 11 03 06 AM

I'm also running into this issue. I assumed there was a problem using this in react-grid-layout / react-resizable wrappers and having ImageMapper completing before knowing parent dimensions, but it's interesting that it is happening in the Storybook link as well.

First render has 0 height and width. Subsequent renders work as expected.

@NishargShah
Copy link
Member

In the first render, you will never get the actual height but after the first render, it will get that and present all the things to the screen.

@rafyzg
Copy link

rafyzg commented May 2, 2022

I am experiencing the same issue.
Specifying the height in advance fixes this problem for me.

@NishargShah
Copy link
Member

Hello

I am working on this issue but in the meantime please downgrade the package to v1.3.0, it's working fine.

https://www.npmjs.com/package/react-img-mapper/v/1.3.0

@NishargShah NishargShah added bug Something isn't working help wanted Extra attention is needed question A valid question labels Jul 9, 2022
@majilan37
Copy link

i been strugling with the issue too, i fixed this by giving width and hieght props

@majilan37
Copy link

i did this and it works

<ImageMapper src={"/images/interactive.png"} width={7740} height={4330} map={{ name: "my-map", areas: mapDataOverview }} onClick={clicked} />

@NishargShah
Copy link
Member

Hello @albmat @majilan37 @rafyzg @KeithHubert Resolved in V1.5.0

Please check and free feel to reopen if you found any bugs related to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question A valid question
Projects
None yet
Development

No branches or pull requests

5 participants