Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cypress/component/modal.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { mount } from 'cypress/vue2'
import NcModal from '../../src/components/NcModal/NcModal.vue'
import type { Component } from 'vue'

describe('NcModal', () => {
it('close button is visible when content is scrolled', () => {
mount(NcModal, {
propsData: {
show: true,
size: 'small',
name: 'Name',
},
slots: {
// Create two div as children, first is 100vh = overflows the content, second just gets some data attribute so we can scroll into view
default: {
render: (h) =>
h('div', [
h('div', { style: 'height: 100vh;' }),
h('div', { attrs: { 'data-cy': 'bottom' } }),
]),
} as Component,
},
})

cy.get('[data-cy="bottom"]').scrollIntoView()
cy.get('button.modal-container__close').should('be.visible')
})
})
15 changes: 11 additions & 4 deletions src/components/NcModal/NcModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ export default {

<!-- Content -->
<div :id="'modal-description-' + randId" class="modal-container">
<!-- @slot Modal content to render -->
<slot />
<!-- Close modal -->
<NcButton v-if="canClose && closeButtonContained"
type="tertiary"
Expand All @@ -283,6 +281,10 @@ export default {
<Close :size="20" />
</template>
</NcButton>
<div class="modal-container__content">
<!-- @slot Modal content to render -->
<slot />
</div>
</div>

<!-- Navigation button -->
Expand Down Expand Up @@ -913,19 +915,24 @@ export default {
/* Content */
.modal-container {
position: relative;
display: block;
overflow: auto; // avoids unecessary hacks if the content should be bigger than the modal
display: flex;
padding: 0;
transition: transform 300ms ease;
border-radius: var(--border-radius-large);
background-color: var(--color-main-background);
color: var(--color-main-text);
box-shadow: 0 0 40px rgba(0, 0, 0, .2);

&__close {
position: absolute;
top: 4px;
right: 4px;
}

&__content {
width: 100%;
overflow: auto; // avoids unecessary hacks if the content should be bigger than the modal
}
}

// Sizing
Expand Down