Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination: handle NaN on props #10623

Merged
merged 2 commits into from Apr 9, 2018
Merged

Pagination: handle NaN on props #10623

merged 2 commits into from Apr 9, 2018

Conversation

ghost
Copy link

@ghost ghost commented Apr 9, 2018

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow Element's contributing guide (中文 | English | Español).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

Pagination component breaks when NaN is passed on the prop currentPage or pageSize. Here is a demo reproducing the issue.

https://jsfiddle.net/xroupdkf/2/
screen shot 2018-04-09 at 5 48 11 pm

I added a little protection code to keep it safe from NaN.

  • With NaN, pageSize returns default value (which is 10).
  • currentPage already had a nice handling code inside internalCurrentPage watcher but it is not invoked at initial phase, so I made it to be called immediately.

It passes all of the test cases and I added more of it.

Thank you for maintaining this amazing repository.

@@ -375,27 +375,30 @@ export default {
pageSize: {
immediate: true,
handler(val) {
this.internalPageSize = val;
this.internalPageSize = isNaN(val) ? 10 : val;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I think it should be 1, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! I though it was 10 because pageSize's default value is 10 as written on prop type definitions.

Am I missing something? Sorry, I'm kind of new to this part.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right.

@Leopoldthecoder Leopoldthecoder merged commit 7932539 into ElemeFE:dev Apr 9, 2018
bluejfox added a commit to setariajs/setaria-ui that referenced this pull request Apr 16, 2018
Merge commit 'e344b24efff83e35ed424f073e3141a3e7068595' into current

* commit 'e344b24efff83e35ed424f073e3141a3e7068595': (60 commits)
  Changelog: fix a 2.3.4 typo (ElemeFE#10710)
  Changelog: update for 2.3.4 (ElemeFE#10703)
  [release] 2.3.4
  [build] 2.3.4
  Changelog: update for 2.3.4 (ElemeFE#10691)
  Rate: fix a method name typo (ElemeFE#10688)
  Types: add missing CheckboxButton export (ElemeFE#10666)
  Table: add $index as formatter's param (ElemeFE#10645)
  Tabs: fix text color for disabled border-card (ElemeFE#10640)
  Select: fix tags style in IE10 (ElemeFE#10632)
  Textarea: fix undefined in ssr when v-model not set (ElemeFE#10630)
  Pagination: disabled prev and next buttons should not trigger click (ElemeFE#10628)
  Pagination: handle NaN on props (ElemeFE#10623)
  Upload: fix duplicated handleClick due to keydown bubbling (ElemeFE#10624)
  Select: fix a wrong variable name (ElemeFE#10618)
  Table: update resizeState when updateColumnsWidth (ElemeFE#10338)
  Pagination: ensure currentPage is updated in current-change handler (ElemeFE#10599)
  i18n: fix a typo in pl.js (ElemeFE#10593)
  Radio: remove native input's offset of radio button (ElemeFE#10592)
  i18n: add ug-CN (ElemeFE#10585)
  ...

# Conflicts:
#	CHANGELOG.zh-CN.md
#	examples/versions.json
#	package.json
#	src/index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant