|
189 | 189 | <!-- Buttons -->
|
190 | 190 | <button
|
191 | 191 | class="flex items-center py-1 px-3 gap-1 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 rounded-s border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
|
192 |
| - @click="page--" :disabled="page <= 1"> |
| 192 | + @click="page--; pageInput = page.toString();" :disabled="page <= 1"> |
193 | 193 | <svg class="w-3.5 h-3.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
194 | 194 | viewBox="0 0 14 10">
|
195 | 195 | <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
201 | 201 | </button>
|
202 | 202 | <button
|
203 | 203 | class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
|
204 |
| - @click="page = 1" :disabled="page <= 1"> |
| 204 | + @click="page = 1; pageInput = page.toString();" :disabled="page <= 1"> |
205 | 205 | <!-- <IconChevronDoubleLeftOutline class="w-4 h-4" /> -->
|
206 | 206 | 1
|
207 | 207 | </button>
|
208 |
| - <div |
| 208 | + <div |
209 | 209 | contenteditable="true"
|
210 | 210 | class="min-w-10 outline-none inline-block w-auto min-w-10 py-1.5 px-3 text-sm text-center text-gray-700 border border-gray-300 dark:border-gray-700 dark:text-gray-400 dark:bg-gray-800 z-10"
|
211 | 211 | @input="page = parseInt($event.target.innerText) || ''"
|
212 | 212 | >
|
213 |
| - {{ page }} |
| 213 | + {{ pageInput }} |
214 | 214 | </div>
|
215 | 215 |
|
216 | 216 | <button
|
217 | 217 | class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-l-0 border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
|
218 |
| - @click="page = totalPages" :disabled="page >= totalPages"> |
| 218 | + @click="page = totalPages; pageInput = page.toString();" :disabled="page >= totalPages"> |
219 | 219 | {{ totalPages }}
|
220 | 220 |
|
221 | 221 | <!-- <IconChevronDoubleRightOutline class="w-4 h-4" /> -->
|
222 | 222 | </button>
|
223 | 223 | <button
|
224 | 224 | class="flex items-center py-1 px-3 gap-1 text-sm font-medium text-gray-900 focus:outline-none bg-white border-l-0 rounded-e border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
|
225 |
| - @click="page++" :disabled="page >= totalPages"> |
| 225 | + @click="page++; pageInput = page.toString();" :disabled="page >= totalPages"> |
226 | 226 | <span class="hidden sm:inline">{{ $t('Next') }}</span>
|
227 | 227 | <svg class="w-3.5 h-3.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
228 | 228 | viewBox="0 0 14 10">
|
@@ -318,6 +318,7 @@ const emits = defineEmits([
|
318 | 318 | ]);
|
319 | 319 |
|
320 | 320 | const checkboxesInternal: Ref<any[]> = ref([]);
|
| 321 | +const pageInput = ref('1'); |
321 | 322 | const page = ref(1);
|
322 | 323 | const sort = ref([]);
|
323 | 324 |
|
@@ -346,6 +347,9 @@ watch(() => props.sort, (newSort) => {
|
346 | 347 | });
|
347 | 348 |
|
348 | 349 | watch(() => props.page, (newPage) => {
|
| 350 | + // page.value and newPage will not be equal only on page load |
| 351 | + // this check prevents cursor jumping on manual input |
| 352 | + if (page.value !== newPage) pageInput.value = newPage.toString(); |
349 | 353 | page.value = newPage;
|
350 | 354 | });
|
351 | 355 |
|
|
0 commit comments