ionic-team / ionic-team/ionic-framework

bug: ion-item-sliding - sliding will not work in Svelte (and possibly others without VDOM)

Abierto
#26,466 3 comentarios 0 reacciones 0 asignados Ver en GitHub
package: core type: bug
Lenguaje dominante
TypeScript
Estrellas
52.7k
Forks
13.3k
Merge medio
1 d 15 h
PR fusionados (30 d)
51

Descripción

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.

### Ionic Framework Version

- [ ] v4.x
- [ ] v5.x
- [X] v6.x
- [ ] Nightly

### Current Behavior

Sliding the options in ion-item-sliding will not work in Svelte(Kit) framework and possibly others that do not use VDOM (assumption)

The part in the Stencil code that seeks ion-item through queryselector is triggered in the `connectedCallback` hook of the webcomponent. This seems to be too early to detect any ion-item that is (to be) rendered as a child. Because of this, `this.item` is always `null` which basically renders the sliding feature useless. Also open/close methods won't work.

After some conversation with an Ionic member on Discord - the suggestion is to have the logic in `connectedCallback` moved to the lifecycle hook `componentDidLoad`.

https://discordapp.com/channels/520266681499779082/1051562091393335316/1051613247989612725

### Expected Behavior

Ion Item Sliding to slide whenever it is used by the user and/or programmatically

### Steps to Reproduce

Spin a svelte ionic project

`npm create ionic-svelte-app@latest`

replace +page.svelte with:

```

import { onMount } from 'svelte';

let itemSlidingStart: HTMLIonItemSlidingElement;
const dragEvent = async (event) => {
console.log('EVEs', event);
// debugger;
const stuff = await itemSlidingStart.getOpenAmount();

console.log('EVE', event, stuff);

// itemSlidingStart.open('start').then((x) => {
// console.log('SSS', x);
// });

// console.log('FIND THE ELEMENT IN SVELTE CODE', itemSlidingStart.querySelector('ion-item'));
};

onMount(() => {
console.log('adsadsa', itemSlidingStart);
});


Mark Unread


Delete

ssss

```

### Code Reproduction URL

https://github.com/sean-perkins/ionic-svelte-item-sliding

### Ionic Info

Ionic core version 6.x

### Additional Information

_No response_

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.