Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable option to hide the X button in a modal #3898

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 13 additions & 11 deletions core/src/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,20 @@
{/if}
</div>
</div>
<div class="fd-bar__right">
<div class="fd-bar__element">
<button
class="fd-button fd-button--transparent fd-button--compact"
on:click={() => dispatch('close', { activeDrawer: false })}
aria-label="close"
data-testid={settings.closebtn_data_testid && isModal ? settings.closebtn_data_testid : 'lui-modal-index-' + modalIndex}
>
<i class="sap-icon sap-icon--decline" />
</button>
{#if settings.hideXBtn !== true}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add this option to the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do.

<div class="fd-bar__right">
<div class="fd-bar__element">
<button
class="fd-button fd-button--transparent fd-button--compact"
on:click={() => dispatch('close', { activeDrawer: false })}
aria-label="close"
data-testid={settings.closebtn_data_testid && isModal ? settings.closebtn_data_testid : 'lui-modal-index-' + modalIndex}
>
<i class="sap-icon sap-icon--decline" />
</button>
</div>
</div>
</div>
{/if}
</div>
{/if}
<div class="fd-dialog__body">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import defaultLuigiConfig from '../../configs/default';
describe('JS-TEST-APP', () => {
const localRetries = {
retries: {
runMode: 4,
openMode: 4
}
};
describe('Configure x btn for a modal', () => {
let newConfig;
beforeEach(() => {
newConfig = structuredClone(defaultLuigiConfig);
newConfig.navigation.nodes[0].children.push({
pathSegment: 'openNodeInModal',
label: 'Open Node in Modal',
viewUrl: '/examples/microfrontends/multipurpose.html',
openNodeInModal: {
title: 'Title for modal',
hideXBtn: true
}
});
newConfig.tag = 'js-test-app-modal-test';
});
it('x-btn not visible', () => {
cy.visitTestApp('/', newConfig);
cy.get('[configversion="js-test-app-modal-test"]');
cy.get('.fd-navigation')
.contains('Open Node in Modal')
.click();
cy.get('.lui-modal-mf .lui-modal-header').should('not.have.attr', 'aria-label', 'close');
});
it('x-btn visible, hideXBtn=false', () => {
newConfig.navigation.nodes[0].children[2].openNodeInModal.hideXBtn = false;
cy.visitTestApp('/', newConfig);
cy.get('[configversion="js-test-app-modal-test"]');
cy.get('.fd-navigation')
.contains('Open Node in Modal')
.click();
cy.get('.lui-modal-mf [aria-label="close"]').should('have.attr', 'data-testid', 'lui-modal-index-0');
});
it('x-btn visible, hideXBtn not defined', () => {
delete newConfig.navigation.nodes[0].children[2].openNodeInModal.hideXBtn;
cy.visitTestApp('/', newConfig);
cy.get('[configversion="js-test-app-modal-test"]');
cy.get('.fd-navigation')
.contains('Open Node in Modal')
.click();
cy.get('.lui-modal-mf [aria-label="close"]').should('have.attr', 'data-testid', 'lui-modal-index-0');
});
});
});