angular / angular/components

[Paginator] Does not emit event when changed programatically

オープン
#8,417 コメント 23 件 リアクション 26 件 担当者 0 名 GitHub で見る
area: material/paginator P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

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

Bug

#### What is the expected behavior?

Changing the page index programmatically should emit a `page` event.

#### What is the current behavior?

Assigning to `.pageIndex` does not emit a `page` event. There is no method to jump to a specified page and ensure that an event is emitted.

#### What are the steps to reproduce?

Open [this plunker](https://embed.plnkr.co/dPr77Z/). Enter a (different) page number in the input at the top of the page and click "Go To". The displayed paginator offset ("11-20") changes but the table results do not.

#### What is the use-case or motivation for changing an existing behavior?

The current behavior is wrong. The documentation for the `page` Output says "Event emitted when the paginator changes the page size or page index"; the page index has changed but the event was not emitted.

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

Still happening as of Beta 12, at least.

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

I checked [paginator.ts](https://github.com/angular/material2/blob/master/src/lib/paginator/paginator.ts) and the event is emitted in various methods that change the page index (next / previous) but not in the setting for pageIndex itself. I don't know why this design decision was made so I hesitate to suggest that it be changed, but we need *some* way to tell the paginator to go to a page as though the user had clicked to get to that page.

In the short term, I noticed that the private method `_changePageSize` is exposed in the typings for this component, and does not check if the size being set is the current size. So I can call

this.paginator._changePageSize(this.paginator.pageSize);

to force the paginator to emit a `page` event. Of course it's a pretty awful hack, but it gets the intended behavior. It'd be nice to avoid this in a future release.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/lib/paginator/paginator.ts から始め、次のページおよび前のページへの変更時に page event が発行される箇所を確認し、リンクされた Plunker を使って問題を再現してください。pageIndex setter と関連する paginator の動作を追跡してください。完了の条件は、プログラムによるページ変更で page event が発行され、利用側のテーブル結果が一貫して更新されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。