diff --git a/cypress/e2e/cardFeatures.js b/cypress/e2e/cardFeatures.js index def7e258d..d2e9000ca 100644 --- a/cypress/e2e/cardFeatures.js +++ b/cypress/e2e/cardFeatures.js @@ -335,6 +335,14 @@ describe('Card', function () { .find('.ProseMirror h1').contains('Hello world writing more text').should('be.visible') }) + it('Shows the card title in the page title', () => { + cy.title().should('match', new RegExp(`^${boardData.title} - Deck - `)) + cy.get('.card:contains("Hello world")').should('be.visible').click() + cy.title().should('match', new RegExp(`^Hello world - ${boardData.title} - Deck - `)) + cy.go('back') + cy.title().should('match', new RegExp(`^${boardData.title} - Deck - `)) + }) + it('Set a due date', function () { const newCardTitle = 'Card with a due date' diff --git a/src/components/Controls.vue b/src/components/Controls.vue index b02512d77..8fea20e15 100644 --- a/src/components/Controls.vue +++ b/src/components/Controls.vue @@ -309,6 +309,7 @@ import { getCurrentUser } from '@nextcloud/auth' import { mapActions, mapState, mapWritableState } from 'pinia' import { useStackStore } from '../stores/stack.js' import { useBoardStore } from '../stores/board.js' +import { useCardStore } from '../stores/card.js' import { useSettingsStore } from '../stores/settings.js' export default { @@ -388,7 +389,15 @@ export default { compactMode: state => state.compactMode, showCardCover: state => state.showCardCover, }), + ...mapState(useCardStore, ['cardById']), ...mapWritableState(useSettingsStore, ['searchQuery']), + pageTitle() { + if (!this.board?.title) { + return '' + } + const cardTitle = this.$route.params.cardId && this.cardById(Number(this.$route.params.cardId))?.title + return cardTitle ? `${cardTitle} - ${this.board.title}` : this.board.title + }, detailsRoute() { return { name: 'board.details', @@ -413,7 +422,7 @@ export default { 'board.id'() { this.clearFilter() }, - 'board.title': { + pageTitle: { immediate: true, handler(title) { if (title) {