Skip to content

Commit 422ce7b

Browse files
committed
disable current page button in Tailwind component
1 parent cff9216 commit 422ce7b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/TailwindPagination.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
v-for="(page, key) in slotProps.computed.pageRange"
4040
:key="key"
4141
v-on="slotProps.pageButtonEvents(page)"
42+
:disabled="page === slotProps.computed.currentPage"
4243
>
4344
{{ page }}
4445
</button>
@@ -70,7 +71,7 @@ export default {
7071
compatConfig: {
7172
MODE: 3
7273
},
73-
74+
7475
inheritAttrs: false,
7576
7677
emits: ['pagination-change-page'],

tests/unit/TailwindPagination.spec.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ test('does not emit event on current page', function () {
146146
expect(event).toBeUndefined();
147147
});
148148

149+
test('current page button is disabled', function () {
150+
exampleData.current_page = 1;
151+
const wrapper = mount(TailwindPagination, {
152+
props: {
153+
data: exampleData,
154+
},
155+
});
156+
157+
const button = wrapper.findAll('button').at(1);
158+
expect(button.attributes('disabled')).toBe('');
159+
});
160+
149161
test('has correct DOM structure when using slots', function () {
150162
const wrapper = mount(TailwindPagination, {
151163
props: { data: exampleData },

0 commit comments

Comments
 (0)