angular / angular/components

Stepper (selectionChange) vs (selectionChanged) and [selectedIndex]

未关闭
#9,733 30 条评论 29 个 reaction 已指派 0 人 在 GitHub 查看
area: cdk/stepper needs: discussion P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

#### Bug, feature request, or proposal:
```


Next


Previous (cancelled)


```
In the stepper control the (selectionChange) event cannot be used together with [selectedIndex], because changing the [selectedIndex] also triggers (selectionChange), so there is no way of cancelling the selection programatically, or implement other logic 'before' the change is executed.

Expected it to work as a standard html select control where:
- when changing the .selectedIndex the (change) event doesn't get automatically triggered
- the (change) event is triggered 'before' the change is finished, so it can be cancelled with event.preventDefault()

#### What is the expected behaviour?
- The current event should be renamed (selectionChange**d**) = 'after' the step has changed.
- Emit a new event (selectionChange) = 'before' the step has changed, with option to cancel the action, which doesn't get automatically triggered when selectedIndex changes.

#### What is the current behavior?
selectionChange = 'after' the step has changed, naming is confusing, gets triggered automatically with [selectedIndex]

#### What are the steps to reproduce?
![screen shot 2018-02-01 at 12 54 07](https://user-images.githubusercontent.com/30979663/35677213-0fd83322-074f-11e8-9029-7c629ecc6c38.png)

1. Select step 2
2. Press Previous button (the action is cancelled programatically) - ok
3. Press step 1 header (step 1 is still selected, the action cannot be cancelled, selectedIndex remains on step 2)

StackBlitz: https://stackblitz.com/edit/angular-material2-issue-9lskal

#### What is the use-case or motivation for changing an existing behavior?
Be able to programatically enable/disable certain steps

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Material 5.1.0

#### Is there anything else we should know?

贡献指南

打开贡献指南

调研方向

首先在链接的 StackBlitz 中复现该行为,重点关注 mat-horizontal-stepper、selectedIndex 和 selectionChange。跟踪用户导航与以编程方式更改 selectedIndex 之间的差异;完成的标准是事件语义彼此不同、可以取消更改前的操作,并且更改后的通知仍然可用。

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

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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