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

Layer Re-ordering is not working within Web component. #1048

Closed
venkatesh-brightly opened this issue Apr 9, 2024 · 6 comments
Closed

Layer Re-ordering is not working within Web component. #1048

venkatesh-brightly opened this issue Apr 9, 2024 · 6 comments
Labels

Comments

@venkatesh-brightly
Copy link
Contributor

I have a web component 'my-map' that is rendering openlayer map. I am using LayerShop Class for layer switcher.

Problem:
When I am trying to re-order the layers, I am not able to drop the layer on top or bottom.

It's working fine outside web component. But not inside web component.

@Viglino
Copy link
Owner

Viglino commented Apr 9, 2024

Do you have an example online to test.
What sort of component are you using ?

@venkatesh-brightly
Copy link
Contributor Author

venkatesh-brightly commented Apr 9, 2024

I am using 'lit' for creating web component.

Please check this link: https://codesandbox.io/p/sandbox/pedantic-leaf-hf2z7d?file=%2Fsrc%2Findex.js

While debugging, I figured out that in move(e) function, e.target and document.elementFromPoint is actually returning the web component instead of the actual node which is preventing it from dropping.

I fixed it by updating the below code for now in my local:

var li
if (!e.touches) {
  li = e.target
  /**
   *  Get the HTML node within web component on click drag
   */
  if(e.target.shadowRoot){
    li = e.composedPath()[0]
  }
} else {
  li = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
  /**
   *  Get actual HTML node within web component on touch drag
   */
  while(li.shadowRoot){
    li = li.shadowRoot.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY)
  }
}

This code can be found in file: LayerSwitcher.js:594

@venkatesh-brightly
Copy link
Contributor Author

I hope this might help.

@Viglino
Copy link
Owner

Viglino commented Apr 9, 2024

I hope this might help.

I'll try to fix it asap

@venkatesh-brightly
Copy link
Contributor Author

When will these changes published on npm?

@Viglino
Copy link
Owner

Viglino commented Apr 10, 2024

Just published ol-ext@4.0.18

@Viglino Viglino added the bug label Apr 10, 2024
@Viglino Viglino closed this as completed Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants