Vue 3 Typescript / Composition API / Pinia – Parent component computed data from store not updated after child send event and update state

I’m having an issue with a parent component data not updated when his child send an event :The parent component displays a changelog :

The changelogsStore.ts (simplified):

export const useChangelogStore = defineStore('changelogs', {  
    currentChangelog: null as ChangelogInterface | null,  
}),  
  
actions: {
setCurrentChangelog(changelog: ChangelogInterface) {
    this.currentChangelog = changelog
    },

async modifyChangelog(changelogId: number, changelogData: NewChangelog, accessToken: string) {
      try {
        const updatedChangelog = await changelogsService.updateChangelog(
          changelogId,
          changelogData,
          accessToken
        )
        const index = this.changelogs.findIndex((changelog) => changelog.id === changelogId)
        if (index !== -1) {
          this.changelogs.splice(index, 1, updatedChangelog)
        }
        return updatedChangelog
      } catch (error) {
        console.error('Failed to update changelog:', error)
      }
    },
}

ChangelogDetails.vue (the parent component, simplified) :

//imports
<template>
    <div>{{ changelog? }}</div>

</template>

<script setup lang="ts">

const changelogStore = useChangelogStore()

const changelog = computed(() => changelogStore.currentChangelog)
</script>

I have a changelogsUsecases.ts :

async updateChangelog(changelogId: number, changelogData: NewChangelog, accessToken: string) {
    return await this.store.modifyChangelog(changelogId, changelogData, accessToken)
  }

ModifyChangelog.component.vue (the child component, simplified):

<template>
  <div>
    <form ... @submit.prevent="onSubmit">
      // fields...
       <button type="submit" class="primary-button">
         {{ $t('cta.confirm') }}
       </button>
    </form>
  <div>
</template>

<script lang="ts" setup>
const sendModificationConfirmation = (updatedChangelogData: NewChangelog) => {
  emit('modificationConfirmationSent', updatedChangelogData)
}

const emit = defineEmits(['close', 'modificationConfirmationSent'])
</script>

The issue is that after updating trough the child, my changelog displayed in ChangelogDetails doesn’t get updated. I need to refresh it to see the changes even though the event is correctly send to his parent (I consoled it), and the changes are made, I also inspected my Network and DB.

Isn’t the computed property supposed to be reactive ?

I tried many things to no avail.

I tried to console.log the changelogStore.currentChangelog and after a refresh it’s “null”.

As I reach the ChangelogDetails from another page, the grand parent called ChangelogTable :

const viewDetails = (changelog: ChangelogInterface) => {
  changelogsStore.setCurrentChangelog(changelog)
  router.push({ name: 'changelog-details', params: { id: changelog.id } })
}

The currentChangelog should be set right ? But it’s not persisted as I understand.

Tried computed / refs property, I also tried to force re render (yet didn’t work)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật