Skip to content

Commit

Permalink
fix: prevent qalendar from resetting to default mode when being resiz…
Browse files Browse the repository at this point in the history
…ed (#98)
  • Loading branch information
tomosterlund authored Nov 20, 2022
1 parent c40fe66 commit e27af87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 19 additions & 1 deletion cypress/e2e/01-smoke.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,22 @@ describe('Rendering the component', () => {
expect(periodNameElement.text()).to.not.equal(periodName)
})
});
})

it('Keeps selected mode on resizing', () => {
// Start in week mode
cy.get('.mode-is-week')

// Change to another mode
cy
// @ts-ignore
.changeMode('month')

cy.get('.mode-is-month')

// Resize the window
cy.viewport(1000, 500).wait(1000)

// Expect to still be in the same mode
cy.get('.mode-is-month')
})
})
4 changes: 1 addition & 3 deletions src/Qalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ export default defineComponent({
this.calendarWidth = calendarRoot.clientWidth;
if (this.calendarWidth < dayModeBreakpoint) this.mode = 'day';
if (this.calendarWidth >= dayModeBreakpoint)
this.mode = this.config?.defaultMode || 'week';
if (this.calendarWidth < dayModeBreakpoint && this.mode !== 'day') this.mode = 'day';
},
setPeriodOnMount() {
Expand Down

0 comments on commit e27af87

Please sign in to comment.