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

fix(browser): orchestrator preventing iframe mouse interaction #5813

Closed
Closed
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
5 changes: 1 addition & 4 deletions packages/browser/src/client/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function createIframe(container: HTMLDivElement, file: string) {

iframe.style.display = 'block'
iframe.style.border = 'none'
iframe.style.pointerEvents = 'none'
iframe.setAttribute('allowfullscreen', 'true')
iframe.setAttribute('allow', 'clipboard-write;')

Expand Down Expand Up @@ -151,10 +150,8 @@ async function createTesters(testFiles: string[]) {
const config = getConfig()
const container = await getContainer(config)

if (config.browser.ui) {
container.className = ''
if (config.browser.ui)
container.textContent = ''
Copy link
Member

@sheremet-va sheremet-va Jun 1, 2024

Choose a reason for hiding this comment

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

Why did you remove this? Only the fallback text should be centered

iframe should touch every border

Copy link
Member Author

Choose a reason for hiding this comment

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

now it is always centered, the container and the iframe will have the same size

Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed also the overflow auto in the container and so centering the content doesn't matter

Copy link
Member

@sheremet-va sheremet-va Jun 1, 2024

Choose a reason for hiding this comment

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

the iframe should not be centered

Copy link
Member

Choose a reason for hiding this comment

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

Can you please explain why you did it and not just state that you did it? I can see the code, I don't see why. The iframe was never meant to be centered

}

if (config.isolate === false) {
createIframe(
Expand Down
37 changes: 35 additions & 2 deletions packages/ui/client/components/BrowserIframe.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<script setup lang="ts">
import { registerResizingListener } from '~/composables/client/resizing'

const viewport = ref('custom')
const resizingContainer = ref(false)

function changeViewport(name: string) {
if (viewport.value === name) {
Expand All @@ -8,6 +11,12 @@ function changeViewport(name: string) {
viewport.value = name
}
}
function onResizing(isResizing: boolean) {
resizingContainer.value = isResizing
}
onMounted(() => {
registerResizingListener(onResizing)
})
</script>

<template>
Expand Down Expand Up @@ -61,30 +70,54 @@ function changeViewport(name: string) {
@click="changeViewport('tablet')"
/>
</div>
<div flex-auto overflow-auto>
<div id="tester-ui" class="flex h-full justify-center items-center font-light op70" style="overflow: auto; width: 100%; height: 100%" :data-viewport="viewport">
<div class="grid scrolls place-items-center" style="height: calc(100vh - 84px)">
<div
id="tester-ui"
class="flex font-light op70"
:class="resizingContainer ? 'resizing': undefined"
:data-viewport="viewport"
>
Select a test to run
</div>
</div>
</div>
</template>

<style>
#tester-ui.resizing iframe {
pointer-events: none;
}
[data-viewport="custom"] {
padding: 11px;
Copy link
Member

Choose a reason for hiding this comment

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

why do you need margins and paddings?

Copy link
Member

Choose a reason for hiding this comment

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

I intentionally removed all paddings

Copy link
Member Author

Choose a reason for hiding this comment

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

It is about the 11px on the left resizer (avoid overlap)

Copy link
Member Author

Choose a reason for hiding this comment

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

I can remove both margin and padding, shouldn't be a problem

Copy link
Member

Choose a reason for hiding this comment

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

There is no overlap, the resizer appears on top of the panel

}
[data-viewport="custom"],
[data-viewport="custom"] iframe {
width: 100%;
height: 100%;
}

[data-viewport="small-mobile"] {
margin: 11px;
}
[data-viewport="small-mobile"],
[data-viewport="small-mobile"] iframe {
width: 320px;
height: 568px;
}

[data-viewport="large-mobile"] {
margin: 11px;
}
[data-viewport="large-mobile"],
[data-viewport="large-mobile"] iframe {
width: 414px;
height: 896px;
}

[data-viewport="tablet-mobile"] {
margin: 11px;
}
[data-viewport="tablet"],
[data-viewport="tablet"] iframe {
width: 834px;
height: 1112px;
Expand Down
24 changes: 24 additions & 0 deletions packages/ui/client/composables/client/resizing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export type ResizingListener = (isResizing: boolean) => void

const resizingSymbol = Symbol.for('resizing')

export function registerResizingListener(listener: ResizingListener) {
inject<(listener: ResizingListener) => void>(resizingSymbol)?.(listener)
}

export function provideResizing() {
const listeners = new Set<ResizingListener>()

function addResizeListener(listener: ResizingListener) {
listeners.add(listener)
}

function notifyResizing(isResizing: boolean) {
for (const listener of listeners)
listener(isResizing)
}

provide(resizingSymbol, addResizeListener)

return { notifyResizing }
}
6 changes: 5 additions & 1 deletion packages/ui/client/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import { Pane, Splitpanes } from 'splitpanes'
import { browserState } from '~/composables/client';
import { coverageUrl, coverageVisible, initializeNavigation } from '../composables/navigation'
import { provideResizing } from '~/composables/client/resizing'

const dashboardVisible = initializeNavigation()
const { notifyResizing } = provideResizing()

const mainSizes = useLocalStorage<[left: number, right: number]>('vitest-ui_splitpanes-mainSizes', [33, 67], {
initOnMounted: true,
})
Expand All @@ -21,6 +24,7 @@ const onModuleResized = useDebounceFn((event: { size: number }[]) => {
event.forEach((e, i) => {
detailSizes.value[i] = e.size
})
notifyResizing(false)
}, 0)

function resizeMain() {
Expand Down Expand Up @@ -48,7 +52,7 @@ function resizeMain() {
<FileDetails v-else />
</transition>
<transition v-else>
<Splitpanes key="detail" @resized="onModuleResized">
<Splitpanes key="detail" @resize="notifyResizing(true)" @resized="onModuleResized">
<Pane :size="detailSizes[0]">
<BrowserIframe v-once />
</Pane>
Expand Down
4 changes: 3 additions & 1 deletion test/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"test:safaridriver": "PROVIDER=webdriverio BROWSER=safari pnpm run test:unit",
"test-fixtures": "vitest",
"test-mocking": "vitest --root ./fixtures/mocking",
"coverage": "vitest --coverage.enabled --coverage.provider=istanbul --browser.headless=yes"
"coverage": "vitest --coverage.enabled --coverage.provider=istanbul --browser.headless=yes",
"test:browser:playwright": "PROVIDER=playwright vitest",
"test:browser:webdriverio": "PROVIDER=webdriverio vitest"
},
"devDependencies": {
"@vitejs/plugin-basic-ssl": "^1.0.2",
Expand Down
Loading