mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 05:43:40 +08:00
The outside-click handler treated Undo/Redo as outside the editor, clearing selection and hiding widget controls. It also misclassified “Add to layout” after its button was removed during the click. Both broke browser workflows. Fixed using the event’s original propagation path to identify clicks inside the editor.
Opening Edit after deselection showed a blank picker and no coordinate controls. Fixed by selecting an active widget, with a fallback to the first widget.
This commit is contained in:
@@ -71,6 +71,7 @@ const projection = JSON.parse(execFileSync(process.env.PYTHON || 'python3', ['-c
|
||||
await page.emulateMedia({reducedMotion:'reduce'})
|
||||
await page.setViewportSize({width:390,height:844})
|
||||
await rows.first().evaluate(row => row.scrollIntoView({block:'center'}))
|
||||
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => requestAnimationFrame(resolve)))))
|
||||
const touchRows = await rows.evaluateAll(elements => {
|
||||
const top = document.querySelector('.gx-layout__sections').getBoundingClientRect().bottom
|
||||
return elements.filter(row => row.getBoundingClientRect().top > top && row.getBoundingClientRect().bottom < innerHeight)
|
||||
@@ -176,9 +177,11 @@ const projection = JSON.parse(execFileSync(process.env.PYTHON || 'python3', ['-c
|
||||
const saveButton = page.getByRole('button', {name:'Save changes', exact:true})
|
||||
assert.equal(await saveButton.isVisible(), true)
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true)
|
||||
await page.evaluate(() => window.editor.deselectWidget())
|
||||
await page.getByRole('button', {name:/^Edit(?: widget)?$/}).click()
|
||||
assert.equal(await page.getByRole('combobox', {name:/^Selected widget/}).isVisible(), true)
|
||||
assert.equal(await page.getByLabel('X', {exact:true}).isVisible(), true)
|
||||
if (width <= 768) assert.equal(await page.locator('.gx-layout__edit').evaluate(el => getComputedStyle(el).gap), '8px')
|
||||
assert.equal(await page.locator('svg.gx-layout__preview .gx-layout__remove').count(), 0)
|
||||
await page.getByRole('button', {name:'Widgets', exact:true}).click()
|
||||
await rows.filter({has:page.locator('.gx-layout__remove')}).first().locator('.gx-layout__remove').click()
|
||||
|
||||
@@ -38,5 +38,20 @@ scrolls.length = 0
|
||||
openEditPanel.call(editor(700, "static"))
|
||||
assert.deepEqual(scrolls, [], "wide screens without pinned tabs never scroll")
|
||||
|
||||
const unselected = editor(108)
|
||||
unselected.activeWidgets = [{ id: "current_speed" }]
|
||||
openEditPanel.call(unselected)
|
||||
assert.equal(unselected.state.selected, "current_speed", "Edit restores a widget after deselection")
|
||||
|
||||
let delayedAlign
|
||||
globalThis.setTimeout = (fn) => { delayedAlign = fn }
|
||||
const switched = editor(500)
|
||||
openEditPanel.call(switched)
|
||||
switched.state.inspectorPanel = "widgets"
|
||||
scrolled = 0
|
||||
scrolls.length = 0
|
||||
delayedAlign()
|
||||
assert.deepEqual(scrolls, [], "a delayed alignment leaves the Widgets scroll position alone")
|
||||
|
||||
assert.match(ONROAD_LAYOUT_TEMPLATE, /@click="openEditPanel\(\)"><span>Edit/)
|
||||
globalThis.setTimeout = realTimeout
|
||||
|
||||
@@ -712,10 +712,10 @@ input[type="range"].gx-slider:active::-moz-range-thumb {
|
||||
margin: -14px -14px 0; padding: 10px 14px; background: var(--layout-solid); border-bottom: 1px solid var(--glass-border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
|
||||
.gx-layout__widget-list { gap: 6px; }
|
||||
.gx-layout__layer { padding: 2px; }
|
||||
/* Scrolled down, the pinned preview shrinks to leave more room for the widget list. */
|
||||
/* Shrink the pinned preview while scrolling. */
|
||||
.gx-layout__preview-card .gx-layout__preview { transition: max-width 180ms ease; }
|
||||
.gx-layout.is-shrunk .gx-layout__preview-card .gx-layout__preview { max-width: min(72%, calc(var(--layout-pin-max) * .72 * var(--layout-ratio, 2))); }
|
||||
/* Keeps the page height steady so the shrink never pulls the scroll back to the top. */
|
||||
/* Preserve scroll space while the preview shrinks. */
|
||||
.gx-layout.is-shrunk .gx-layout__workspace { padding-bottom: calc(var(--layout-pin-h, 0px) * .4); }
|
||||
.gx-layout.is-shrunk .gx-layout__scene-note { display: none; }
|
||||
.gx-layout.is-shrunk .gx-layout__preview-bar .gx-field { min-height: 34px; }
|
||||
@@ -780,7 +780,7 @@ input[type="range"].gx-slider:active::-moz-range-thumb {
|
||||
|
||||
/* Narrow editors keep each widget's Edit controls compact so less scrolling is needed. */
|
||||
@container (max-width: 1040px) {
|
||||
.gx-layout__edit { gap: 8px; }
|
||||
.gx-layout__inspector .gx-layout__edit { gap: 8px; }
|
||||
.gx-layout__inspector .gx-select.gx-field { padding-block: 0; }
|
||||
.gx-layout__edit .gx-row { min-height: 48px; padding: 6px 12px; }
|
||||
.gx-layout__edit .gx-layout__coordinates { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 8px; row-gap: 6px; }
|
||||
|
||||
@@ -55,7 +55,7 @@ let makerPagesOpen = 0
|
||||
// Screen pixels a pointer may wobble before a press on a preview widget becomes a drag.
|
||||
const DRAG_SLOP = 6
|
||||
const CAMERA_IDS = ["pip_left", "pip_right"]
|
||||
// A finger on a widget that is not armed waits this long before it grabs, so swipes scroll past.
|
||||
// Let swipes scroll before an unarmed widget grabs.
|
||||
const HOLD_MS = 220
|
||||
|
||||
export class OnroadLayoutFeed {
|
||||
@@ -568,7 +568,7 @@ export const OnroadLayoutPage = {
|
||||
.slice().reverse().map(id => this.widgets.find(widget => widget.id === id)).filter(widget => widget && this.layout[widget.id].enabled)
|
||||
},
|
||||
cameraIds() { return CAMERA_IDS.filter(id => Object.hasOwn(this.profile?.widgets || {}, id)) },
|
||||
// Side cameras in the unbroken run of front slots, under only the always-frontmost controls.
|
||||
// Cameras directly below the frontmost controls.
|
||||
camerasOnTop() {
|
||||
const order = orderedWidgetIds(this.state.draft, this.state.data.metadata, this.state.profile)
|
||||
.filter(id => !this.profile.widgets[id]?.frontmost)
|
||||
@@ -576,7 +576,6 @@ export const OnroadLayoutPage = {
|
||||
for (let index = order.length - 1; index >= 0 && this.cameraIds.includes(order[index]); index--) top.push(order[index])
|
||||
return top
|
||||
},
|
||||
// Each side camera locks on its own; a locked one stays in front of every unlocked widget.
|
||||
lockedCameraIds() { return this.camerasOnTop.filter(id => !this.state.pipUnlocked[id]) },
|
||||
listWidgets() { return this.state.layerDrag ? this.state.layerDrag.rows.map(id => this.widgets.find(widget => widget.id === id)) : this.layerWidgets },
|
||||
selectionBox() {
|
||||
@@ -692,7 +691,8 @@ export const OnroadLayoutPage = {
|
||||
this.observePinned()
|
||||
this._onOutsideClick = (event) => {
|
||||
const target = event.target
|
||||
if (!target?.closest || target.closest(".gx-layout__workspace, .gx-select-menu, [role='listbox'], [role='dialog'], dialog, .gx-dialog")) return
|
||||
if (event.composedPath().includes(this.$el) || !target?.closest ||
|
||||
target.closest(".gx-select-menu, [role='listbox'], [role='dialog'], dialog, .gx-dialog")) return
|
||||
this.deselectWidget()
|
||||
}
|
||||
document.addEventListener("click", this._onOutsideClick)
|
||||
@@ -776,6 +776,7 @@ export const OnroadLayoutPage = {
|
||||
if (!event.target?.closest?.(".gx-layout__widget")) this.deselectWidget()
|
||||
},
|
||||
openEditPanel() {
|
||||
if (this.state.selected == null) this.state.selected = this.activeWidgets?.[0]?.id || this.widgets?.[0]?.id || null
|
||||
this.state.inspectorPanel = "edit"
|
||||
this.revealEditPanel()
|
||||
},
|
||||
@@ -783,6 +784,7 @@ export const OnroadLayoutPage = {
|
||||
revealEditPanel() {
|
||||
if (typeof window === "undefined") return
|
||||
const align = () => {
|
||||
if (this.state.inspectorPanel !== "edit") return
|
||||
const tabs = this.$refs.sections, panel = this.$refs.editPanel
|
||||
if (!tabs || !panel || getComputedStyle(tabs).position !== "sticky") return
|
||||
const gap = panel.getBoundingClientRect().top - tabs.getBoundingClientRect().bottom - 8
|
||||
@@ -1256,7 +1258,7 @@ export const OnroadLayoutPage = {
|
||||
startDrag(id, event, fromTray = false) {
|
||||
if (!this.editable || event.button > 0 || this.state.drag || !Object.hasOwn(this.profile.widgets, id)) return
|
||||
if (fromTray && this.profile.widgets[id].available === false) return
|
||||
// Soft lock: a finger grabs only an armed widget at once; others need a tap first or a short hold.
|
||||
// Unarmed widgets need a tap or hold before dragging.
|
||||
if (event.pointerType === "touch" && !fromTray && this.state.touchArmed !== id) {
|
||||
this.clearPendingTouch()
|
||||
this._pendingTouch = { id, pointerId: event.pointerId, pointerType: "touch", clientX: event.clientX, clientY: event.clientY }
|
||||
|
||||
Reference in New Issue
Block a user