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
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
display: block;
overflow: auto;

// The dialog container should completely fill its parent overlay element.
width: 100%;
Copy link
Member

Choose a reason for hiding this comment

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

Peux tu ajouter un test qui permet de démontrer que si je mets 2 contenus (de tailles différentes), la modale aura une taille différente ?

C'est pour s'assurer que width/height:100% n'est pas récupéré par un parent (ou un possible parent lors des prochains commits) afin d'éviter des regressions

Copy link
Member

Choose a reason for hiding this comment

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

EDIT: peut être que le test ne devrait pas être sur le contenu de la modale mais en rapport avec l'element parent.

height: 100%;

// Since the dialog won't stretch to fit the parent, if the height
// isn't set, we have to inherit the min and max values explicitly.
min-height: inherit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
&.bao-modal-sm {
width: 500px;
height: auto;
max-height: calc(100% - 4rem);
}
}

Expand All @@ -98,10 +99,12 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
&.bao-modal-md {
width: 800px;
height: auto;
max-height: calc(100% - 4rem);
}
&.bao-modal-sm {
width: 500px;
height: auto;
max-height: calc(100% - 4rem);
}
}
}
Expand Down
56 changes: 56 additions & 0 deletions projects/angular-ui/src/lib/modal/tests/modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ class AddressComponent {
) {}
}

@Component({
template:
" \
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> \
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> \
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> \
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> \
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> \
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> \
"
})
class LongTextComponent {
constructor(
public modalRef: BaoModalRef<LongTextComponent>,
public modalInjector: Injector
) {}
}

@Injectable({
providedIn: 'root'
})
Expand Down Expand Up @@ -134,6 +152,44 @@ describe('BaoModalComponent', () => {
).toBeNull();
}));

it('Should adjust to content length', () => {
const modalRef = modal.open(AddressComponent, {
size: eModalDesktopWidthSize.SMALL
});

viewContainerFixture.detectChanges();
const smallOverlay =
overlayContainerElement.querySelector('.cdk-overlay-pane');
const smallContentHeight = smallOverlay.clientHeight;

modalRef.close();

viewContainerFixture.detectChanges();
modal.open(LongTextComponent, {
size: eModalDesktopWidthSize.SMALL
});

viewContainerFixture.detectChanges();
const longOverlay =
overlayContainerElement.querySelector('.cdk-overlay-pane');
const longContentHeight = longOverlay.clientHeight;

expect(smallContentHeight).toBeLessThan(longContentHeight);
});

it('Should not exceed viewport height', () => {
modal.open(LongTextComponent, {
size: eModalDesktopWidthSize.SMALL
});

viewContainerFixture.detectChanges();
const overlay =
overlayContainerElement.querySelector('.cdk-overlay-pane');
const longContentHeight = overlay.clientHeight;

expect(longContentHeight).toBeLessThanOrEqual(window.innerHeight);
});

it('should use the default value (small on desktop and fullwidth on mobile)', () => {
modal.open(AddressComponent);

Expand Down