mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 00:26:34 +03:00
fix: scrolling to the first item (#1753)
This commit is contained in:
parent
3f6bf5febb
commit
bccd21394e
|
@ -25,6 +25,29 @@ describe('Menu', () => {
|
|||
.should('be.visible');
|
||||
});
|
||||
|
||||
it('should sync active menu items while scroll back and scroll again', () => {
|
||||
cy.contains('h2', 'Add a new pet to the store')
|
||||
.scrollIntoView()
|
||||
.wait(100)
|
||||
.get('[role=menuitem].active')
|
||||
.children()
|
||||
.last()
|
||||
.should('have.text', 'Add a new pet to the store')
|
||||
.should('be.visible');
|
||||
|
||||
cy.contains('h1', 'Swagger Petstore')
|
||||
.scrollIntoView()
|
||||
.wait(100)
|
||||
|
||||
cy.contains('h1', 'Introduction')
|
||||
.scrollIntoView()
|
||||
.wait(100)
|
||||
.get('[role=menuitem].active')
|
||||
.should('have.text', 'Introduction');
|
||||
|
||||
cy.url().should('include', '#section/Introduction');
|
||||
});
|
||||
|
||||
it('should update URL hash when clicking on menu items', () => {
|
||||
cy.contains('[role=menuitem].-depth1', 'pet').click({ force: true });
|
||||
cy.location('hash').should('equal', '#tag/pet');
|
||||
|
|
|
@ -210,6 +210,7 @@ export class MenuStore {
|
|||
|
||||
this.deactivate(this.activeItem);
|
||||
if (!item) {
|
||||
this.activeItemIdx = -1;
|
||||
this.history.replace('', rewriteHistory);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user