ionic-team / ionic-team/ionic-framework

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

未关闭
#26,466 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
package: core type: bug
主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
1 天 15 小时
30 天内合并 PR
51

描述

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

贡献指南

打开贡献指南

调研方向

Start with the ion-item-sliding implementation and trace the connectedCallback logic that queries for ion-item. Reproduce the issue with the linked ionic-svelte-item-sliding project, then verify that sliding and the open/close methods work in Svelte and other non-VDOM cases after the lifecycle behavior is corrected.

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
frontend, web-dev
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。