ionic-team / ionic-team/ionic-framework

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

Đang mở
#26,466 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
package: core type: bug
Ngôn ngữ chính
TypeScript
Star
52.7k
Fork
13.3k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
51

Mô tả

### 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_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.