Skip to content

Commit 469b228

Browse files
authoredNov 2, 2021
chore(app): basic style and example to stop scrollIntoView bug (#18736)
* style * style
1 parent a5a232d commit 469b228

File tree

3 files changed

+61
-29
lines changed

3 files changed

+61
-29
lines changed
 

‎packages/app/src/layouts/default.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="h-screen overflow-hidden flex flex-row">
3-
<main class="min-w-0 flex-1 border-t border-gray-200 lg:flex">
3+
<main class="h-screen min-w-0 flex-1 border-t border-gray-200 lg:flex">
44
<section
55
aria-labelledby="primary-heading"
66
class="min-w-0 flex-1 h-full flex flex-col overflow-hidden lg:order-last"

‎packages/app/src/navigation/SidebarNavigation.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="flex relative flex-col flex-1 min-h-0 bg-gray-1000">
33
<div
4-
class="absolute cursor-pointer bg-gray-1000 w-8px bottom-0 top-0 right-0 hover:bg-indigo-300"
4+
class="absolute cursor-pointer bg-gray-800 w-2px hover:w-8px bottom-0 top-0 right-0 hover:bg-indigo-300"
55
@click="mainStore.toggleNavBar"
66
/>
77
<div class="flex flex-col flex-1 pt-5 pb-4 overflow-y-auto">

‎packages/app/src/spec/SpecRunner.vue

+59-27
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11
<template>
22
<div
3-
id="main-grid"
4-
class="grid p-12 gap-8 h-full"
3+
id="main-pane"
4+
class="flex"
55
>
6-
<div>
6+
<div
7+
id="inline-spec-list"
8+
class="bg-gray-1000 w-128"
9+
>
710
<InlineSpecList :gql="props.gql" />
811
</div>
912

10-
<div
11-
id="runner"
12-
:style="`width: ${runnerColumnWidth}px`"
13-
class="relative"
14-
>
15-
<SpecRunnerHeader :gql="props.gql" />
13+
<div class="w-128">
1614
<div
17-
:id="RUNNER_ID"
18-
class="viewport origin-top-left"
19-
:style="viewportStyle"
15+
v-once
16+
:id="REPORTER_ID"
2017
/>
21-
<SnapshotControls :event-manager="eventManager" />
2218
</div>
2319

2420
<div
25-
v-once
26-
:id="REPORTER_ID"
27-
/>
21+
ref="runnerPane"
22+
class="relative w-full"
23+
>
24+
<div class="bg-white p-4 border-8 border-blue-300">
25+
<SpecRunnerHeader :gql="props.gql" />
26+
</div>
27+
28+
<div class="flex justify-center bg-gray-100 h-full p-4">
29+
<div
30+
:id="RUNNER_ID"
31+
class="viewport origin-top-left"
32+
:style="viewportStyle"
33+
/>
34+
</div>
35+
<SnapshotControls :event-manager="eventManager" />
36+
</div>
2837
</div>
2938
</template>
3039

3140
<script lang="ts" setup>
32-
import { computed, onBeforeUnmount, onMounted, watch } from 'vue'
41+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
3342
import { REPORTER_ID, RUNNER_ID, getRunnerElement, getReporterElement, empty } from '../runner/utils'
3443
import { gql } from '@urql/core'
3544
import type { SpecRunnerFragment } from '../generated/graphql'
@@ -47,16 +56,25 @@ fragment SpecRunner on App {
4756
}
4857
`
4958
50-
const runnerColumnWidth = 400
5159
const eventManager = window.UnifiedRunner.eventManager
5260
5361
const autStore = useAutStore()
5462
63+
const runnerPane = ref<HTMLDivElement>()
64+
5565
const viewportStyle = computed(() => {
66+
if (!runnerPane.value) {
67+
return
68+
}
69+
70+
const scale = runnerPane.value.clientWidth < autStore.viewportDimensions.width
71+
? runnerPane.value.clientWidth / autStore.viewportDimensions.width
72+
: 1
73+
5674
return `
5775
width: ${autStore.viewportDimensions.width}px;
5876
height: ${autStore.viewportDimensions.height}px;
59-
transform: scale(${runnerColumnWidth / autStore.viewportDimensions.width});`
77+
transform: scale(${scale});`
6078
})
6179
6280
const props = defineProps<{
@@ -90,17 +108,32 @@ onBeforeUnmount(() => {
90108
91109
</script>
92110

93-
<style scoped>
94-
#main-grid {
95-
grid-template-columns: 1fr 2fr 2fr;
111+
<style scoped lang="scss">
112+
$navbar-width: 80px;
113+
114+
#main-pane {
115+
/** There is a "bug" caused by this line:
116+
https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/actionability.ts#L375
117+
Basically `scrollIntoView` is applied even outside of the <iframe>,
118+
scrolling an element "upwards", messing up the UI
119+
Easiest way to reprodudce is remove the `position: fixed`
120+
and run the `SpecList.spec.tsx` test in runner-ct
121+
in CT mode.
122+
Ideally we should not need `position: fixed`, but I don't see
123+
a good way to work around this right now.
124+
*/
125+
position: fixed;
126+
left: $navbar-width;
127+
height: 100vh;
128+
width: calc(100% - #{$navbar-width});
96129
}
97130
98-
.viewport {
99-
border: 2px dotted blue;
131+
#inline-spec-list {
132+
border-right: 2px solid rgb(67 73 97);
100133
}
101134
102-
#runner {
103-
border: 1px solid black;
135+
.viewport {
136+
border: 2px dotted blue;
104137
}
105138
106139
#unified-runner {
@@ -109,7 +142,6 @@ onBeforeUnmount(() => {
109142
110143
#unified-reporter {
111144
position: relative;
112-
width: 300px;
113145
height: 100%;
114146
}
115147

0 commit comments

Comments
 (0)