Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pagination+pagination-nav): disabled styling now works in BS V4.…
…beta.2 (#1381) * feat(pagination): disabled styling now works in BS V4.beta.2 Removing custom style for disabled links as it is now working in native bootstrap V4.beta.2 CSS * pagination: remove no longer needed CSS
- Loading branch information
1 parent
19ba693
commit d51349f
Showing
2 changed files
with
127 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,77 +1,71 @@ | |||
<style> | <style> | ||
.b-pagination .page-item { | .b-pagination .page-item { | ||
-webkit-user-select: none; | |||
-moz-user-select: none; | |||
-ms-user-select: none; | |||
user-select: none; | user-select: none; | ||
} | } | ||
.b-pagination .page-item.disabled { | /* Bootstrap V4.beta.2 (and beta.1) missing focus styling for active link */ | ||
cursor: not-allowed; | |||
opacity: .65; | |||
} | |||
.b-pagination .page-item .page-link.active:focus { | .b-pagination .page-item .page-link.active:focus { | ||
box-shadow: 0 0 0 3px rgba(0,123,255,.5); | box-shadow: 0 0 0 3px rgba(0,123,255,.5); | ||
z-index: 1; | z-index: 1; | ||
} | } | ||
</style> | </style> | ||
|
|
||
<script> | <script> | ||
import { paginationMixin } from '../../mixins'; | import { paginationMixin } from '../../mixins' | ||
import { isVisible } from '../../utils/dom'; | import { isVisible } from '../../utils/dom' | ||
import { KeyCodes } from '../../utils'; | import { KeyCodes } from '../../utils' | ||
const props = { | const props = { | ||
perPage: { | perPage: { | ||
type: Number, | type: Number, | ||
default: 20 | default: 20 | ||
}, | }, | ||
totalRows: { | totalRows: { | ||
type: Number, | type: Number, | ||
default: 20 | default: 20 | ||
}, | }, | ||
ariaControls: { | ariaControls: { | ||
type: String, | type: String, | ||
default: null | default: null | ||
} | } | ||
}; | } | ||
// Our render function is brought in from the pagination mixin | // Our render function is brought in from the pagination mixin | ||
export default { | export default { | ||
mixins: [ paginationMixin ], | mixins: [ paginationMixin ], | ||
props, | props, | ||
computed: { | computed: { | ||
numberOfPages() { | numberOfPages() { | ||
const result = Math.ceil(this.totalRows / this.perPage); | const result = Math.ceil(this.totalRows / this.perPage) | ||
return (result < 1) ? 1 : result; | return (result < 1) ? 1 : result | ||
} | |||
}, | |||
methods: { | |||
// These methods are used by the render function | |||
onClick(num, evt) { | |||
// Handle edge cases where number of pages has changed (i.e. if perPage changes) | |||
if (num > this.numberOfPages) { | |||
num = this.numberOfPages | |||
} else if (num < 1) { | |||
num = 1 | |||
} | |||
this.currentPage = num; | |||
this.$nextTick(() => { | |||
// Keep the current button focused if possible | |||
const target = evt.target | |||
if (isVisible(target) && this.$el.contains(target) && target.focus) { | |||
target.focus() | |||
} else { | |||
this.focusCurrent() | |||
} | } | ||
}) | |||
this.$emit('change', this.currentPage) | |||
}, | }, | ||
methods: { | makePage(pagenum) { | ||
// These methods are used by the render function | return pagenum | ||
onClick(num, evt) { | }, | ||
// Handle edge cases where number of pages has changed (i.e. if perPage changes) | linkProps(pagenum) { | ||
if (num > this.numberOfPages) { | return { href: '#' } | ||
num = this.numberOfPages; | |||
} else if (num < 1) { | |||
num = 1; | |||
} | |||
this.currentPage = num; | |||
this.$nextTick(() => { | |||
// Keep the current button focused if possible | |||
const target = evt.target; | |||
if (isVisible(target) && this.$el.contains(target) && target.focus) { | |||
target.focus(); | |||
} else { | |||
this.focusCurrent(); | |||
} | |||
}); | |||
this.$emit('change', this.currentPage); | |||
}, | |||
makePage(pagenum) { | |||
return pagenum; | |||
}, | |||
linkProps(pagenum) { | |||
return { href: '#' }; | |||
} | |||
} | } | ||
}; | } | ||
} | |||
</script> | </script> |