HOTFIX: OrderCatalog scroll To Item #1026

Merged
jsegarra merged 9 commits from hotfix_scrollToItem into master 2024-12-09 08:44:08 +00:00
1 changed files with 7 additions and 8 deletions
Showing only changes of commit 98b8124577 - Show all commits

View File

@ -78,17 +78,16 @@ watch(
{ immediate: true }
);
const onItemSaved = (updatedItem) => {
scrollToItem(updatedItem.items[0].itemFk);
requestAnimationFrame(() => {
scrollToItem(updatedItem.items[0].itemFk);
});
};
const scrollToItem = async (id) => {
Review

Y si lo tuviese que cargar tardase 101ms ya no iria?

Y si lo tuviese que cargar tardase 101ms ya no iria?
Review

Le puse el nextTick para que el DOM terminase de montarse pero no terminaba de funcionar
Con el setTimeout conseguí el efecto deseado
Iría de todas maneras porque el timeout no depende de la petición anterior

Le puse el nextTick para que el DOM terminase de montarse pero no terminaba de funcionar Con el setTimeout conseguí el efecto deseado Iría de todas maneras porque el timeout no depende de la petición anterior
Review
https://chatgpt.com/c/675000bd-53e8-8011-8a7a-0481f274180d
Review

Resuelto con requestAnimationFrame
He usado un console.error y solo se muestra 1 vez

Resuelto con requestAnimationFrame He usado un console.error y solo se muestra 1 vez
await nextTick();
setTimeout(() => {
const element = itemRefs.value[id]?.$el;
if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}, 100);
const element = itemRefs.value[id]?.$el;
if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
};
provide('onItemSaved', onItemSaved);
</script>