Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix(drawer): Fixes an issue where drawer backdrop was overlaying the …
Browse files Browse the repository at this point in the history
…drawer body.

Fixes #91 and a regression that was introduced by #605.
  • Loading branch information
Lukas Holzer authored and lukasholzer committed Feb 25, 2020
1 parent ca27982 commit 30979f1
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 28 deletions.
37 changes: 30 additions & 7 deletions apps/components-e2e/src/components/drawer/drawer.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Selector, ClientFunction } from 'testcafe';

import { ClientFunction, Selector } from 'testcafe';
import {
isCloseTo,
resetWindowSizeToDefault,
waitForAngular,
} from '../../utils';
import {
closeButton,
createRange,
overlay,
rangeSelection,
selection,
} from '../chart/selection-area/selection-area.po';
import {
isCloseTo,
waitForAngular,
resetWindowSizeToDefault,
} from '../../utils';

const openCount = Selector('#open-count');
const closeCount = Selector('#close-count');
Expand All @@ -39,6 +38,8 @@ const overlayContainer = Selector('.dt-overlay-container');
const heatfieldToggle = Selector('.dt-chart-heatfield-marker');
const heatfieldOverlay = Selector('.dt-chart-heatfield-overlay');
const rangeOverlay = Selector('.dt-chart-selection-area-overlay');
const backDrop = Selector('.dt-drawer-backdrop');
const zIndexTest = Selector('#content-trigger');

const scrollDistance = 50;
const scrollDown = ClientFunction(distance => {
Expand Down Expand Up @@ -156,3 +157,25 @@ test('should move selection area overlay with the chart on scroll', async (testC
.expect(overlay.exists)
.notOk();
});

test('should check if a hover is possible in the drawer over mode', async (testController: TestController) => {
await testController
.click(open)
.resizeWindow(800, 800)
.wait(250)
.expect(backDrop.visible)
.ok()
.hover(overlayTrigger, { speed: 0.3 })
.expect(overlayContainer.exists)
.ok();
});

test('should check if a hover is possible in the drawer over mode', async (testController: TestController) => {
await testController
.click(open)
.resizeWindow(800, 800)
.wait(250)
.hover(zIndexTest, { speed: 0.3 })
.expect(overlayContainer.exists)
.notOk();
});
9 changes: 6 additions & 3 deletions apps/components-e2e/src/components/drawer/drawer.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(closed)="close()"
style="width: 80%; height: 3000px;"
>
<dt-chart id="chart" [series]="series$ | async" [options]="options">
<dt-chart id="chart" [series]="series$ | async" [options]="options">
<dt-chart-tooltip>
<ng-template let-tooltip>
<div style="min-width: 100px;">
Expand Down Expand Up @@ -63,8 +63,11 @@
</dt-drawer>
<span id="open-count">{{openCount}}</span>
<span id="close-count">{{closeCount}}</span>
<button id="content-trigger" [dtOverlay]="overlay">
Hover me
</button>
</dt-drawer-container>
<br />
<button (click)="drawer.open()" id="open" #openButton></button>
<button (click)="drawer.close()" id="close" #closeButton></button>
<button (click)="drawer.open()" id="open" #openButton>open</button>
<button (click)="drawer.close()" id="close" #closeButton>close</button>
</section>
7 changes: 7 additions & 0 deletions apps/components-e2e/src/components/drawer/drawer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#content-trigger {
position: absolute;
top: 0;
right: 0;
// this is the highest possible z-index (integer max range)
z-index: 2147483647;
}
28 changes: 12 additions & 16 deletions apps/components-e2e/src/components/drawer/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import {
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { DataService } from '../../services/data.service';
import { options } from '../chart/chart-options';
import { options as chartOptions } from '../chart/chart-options';

@Component({
selector: 'dt-e2e-drawer',
templateUrl: 'drawer.html',
styleUrls: ['drawer.scss'],
})
export class DtE2EDrawer {
openCount = 0;
Expand All @@ -36,7 +37,7 @@ export class DtE2EDrawer {
validRange = false;
lastTimeframe: [number, number];

options = options;
options = chartOptions;
// Added type here due to missing support for type inference on windows with typescript 3.4.5
// error TS2742: The inferred type of 'series$' cannot be named without a reference to '...@types/highcharts'.
// This is likely not portable. A type annotation is necessary.
Expand All @@ -48,17 +49,12 @@ export class DtE2EDrawer {
)
.pipe(map(result => result.data));

@ViewChild('container', { static: true }) container: DtDrawerContainer;
@ViewChild('drawer', { static: true }) drawer: DtDrawer;
@ViewChild('toggleButton', { static: true }) drawerButton: ElementRef<
HTMLButtonElement
>;
@ViewChild('openButton', { static: true }) openButton: ElementRef<
HTMLButtonElement
>;
@ViewChild('closeButton', { static: true }) closeButton: ElementRef<
HTMLButtonElement
>;
@ViewChild('container', { static: true })
container: DtDrawerContainer;
@ViewChild('drawer', { static: true })
drawer: DtDrawer;
@ViewChild('toggleButton', { static: true })
drawerButton: ElementRef<HTMLButtonElement>;

@ViewChild(DtChartRange, { static: false }) dtChartRange: DtChartRange;

Expand All @@ -79,9 +75,9 @@ export class DtE2EDrawer {
this.lastTimeframe = [0, 0];
}

onTimeframeChanges(timeframe: [number, number] | number): void {
if (Array.isArray(timeframe)) {
this.lastTimeframe = timeframe;
onTimeframeChanges(timeFrame: [number, number] | number): void {
if (Array.isArray(timeFrame)) {
this.lastTimeframe = timeFrame;
}
}
}
12 changes: 11 additions & 1 deletion components/drawer/src/drawer-container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

$dt-backdrop-opacity: 0.4;

/**
* z-index Hierarchy:
*
* .dt-drawer-content: 1
* .dt-drawer-backdrop: 2
* dt-drawer: 3
*/

:host {
position: relative;
display: flex;
Expand All @@ -17,7 +25,7 @@ $dt-backdrop-opacity: 0.4;
opacity: 0;
// Translate3d is faster than translateX because it uses hardware acceleration
transform: translate3d(-100%, 0, 0);
z-index: 3;
z-index: 2;

:host.dt-drawer-is-open > & {
opacity: $dt-backdrop-opacity;
Expand All @@ -27,6 +35,8 @@ $dt-backdrop-opacity: 0.4;
}

.dt-drawer-content {
position: relative;
z-index: 1;
flex-grow: 1;
flex-shrink: 1;
display: block;
Expand Down
3 changes: 2 additions & 1 deletion components/drawer/src/drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
transform: translate3d(-100%, 0, 0);
outline: none;
will-change: transform;
z-index: 2;
// drawer backdrop has a z-index of 2
z-index: 3;

&.dt-drawer-end {
right: 0;
Expand Down

0 comments on commit 30979f1

Please sign in to comment.