fix(macos): make window draggable via data-tauri-drag-region - #29
Open
AranyiRaz wants to merge 1 commit into
Open
fix(macos): make window draggable via data-tauri-drag-region#29AranyiRaz wants to merge 1 commit into
AranyiRaz wants to merge 1 commit into
Conversation
The window used titleBarStyle "Overlay" (no native draggable title bar) while the only drag mechanism in the app was -webkit-app-region, an Electron-only CSS property that WKWebView parses and silently ignores. Result: no draggable surface anywhere on macOS. Add a persistent 40px drag strip at the top of the window, rendered only under Tauri, covering the band both headers already reserve as empty padding for the traffic lights. Grant core:window:allow-start-dragging, which is not part of core:window:default and so was rejected at the ACL layer. Remove the three inert -webkit-app-region declarations. The strip is a dedicated empty element rather than an attribute on the headers because tauri 2.10.3's injected handler matches the attribute on e.target only, with no ancestor walk -- tagging a header would leave its title and subtitle children undraggable. A persistent strip also avoids dead zones during the loading and Suspense states, which render no header at all. z-index 50 keeps it below every blocking overlay so modal semantics are preserved.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS the window cannot be moved with the mouse — there is no draggable surface anywhere.
Two things combine to cause it:
No native title bar to drag.
tauri.conf.jsonsets"titleBarStyle": "Overlay"+"hiddenTitle": true. Overlay mode removes the native draggable title bar and leaves only floating traffic lights over the webview, making the app responsible for supplying its own drag region.The drag region was written for the wrong framework. The only drag mechanism in the codebase was
-webkit-app-region: drag— an Electron-only, non-standard CSS property. WKWebView (which Tauri uses on macOS) does not implement it; it parses and is silently ignored. Tauri's actual mechanism, thedata-tauri-drag-regionattribute, appeared zero times in the repo.The intent was already there:
.tauri-app .sidebar-headerand.tauri-app .content-headeraddpadding-top: 40pxspecifically to clear the traffic lights. The headers were designed as a custom title bar — only the drag mechanism targeted Electron's API instead of Tauri's.Fix
src/App.tsx— one persistent empty 40px drag strip at the top ofapp-layout, rendered only under Tauri via the existing module-levelisTauriconst.src/index.css—.titlebar-dragstyle; removed the three inert-webkit-app-regiondeclarations.src-tauri/capabilities/default.json— grantedcore:window:allow-start-dragging.No page components touched.
Why a dedicated element instead of tagging the headers
The injected handler at the pinned
tauriversion (2.10.3,crates/tauri/src/window/scripts/drag.js) reads the attribute offe.targetonly:No ancestor walk. Putting the attribute on
.content-headerwould make only the header's own padding draggable — mousedown on the<h1>or subtitle<span>setse.targetto that child, which has no attribute, so most of the visible header would stay dead. (tauri'sdevbranch has since gained ancestor-walking and a"deep"value, but neither exists in 2.10.3.)A persistent strip also avoids dead zones:
.content-headeris rendered independently by each page and unmounted on every page switch, and two states render no header at all —Dashboard's loading branch and theSuspensefallback for lazy pages. A header-based region would intermittently not exist.Why the permission is required
core:window:defaultat tagtauri-v2.10.3lists 27 permissions andallow-start-draggingis not among them, while the capability file granted nocore:window:*permission at all. Without the explicit grant,plugin:window|start_draggingis rejected at the ACL layer and dragging silently fails even with the attribute wired correctly.allow-internal-toggle-maximizeis in the default set, so double-click-to-zoom needs nothing extra.Z-index
The strip sits at
z-index: 50, deliberately below every blocking overlay so modal semantics are preserved (.modal-overlay100,.ctx-overlay200,.tour-backdrop901,.wizard-overlay1000). It carries nobackground(headers show through) and nopointer-events: none(it must receive mousedown).Testing
Verified manually on macOS with
npm run tauri dev: window drags, double-click zooms/restores, traffic lights still respond, headers remain fully interactive, modals still block dragging, and no dead zone during loading states.Also passing:
npx tsc --noEmit,npm run build, andgrep -rn "webkit-app-region" src/returns nothing.No automated test accompanies this — the repo has no test infrastructure, and the behaviour is native window dragging that can only be confirmed on macOS hardware.
Out of scope
Not extracting a shared
<PageHeader>. The 17.content-headeroccurrences deviate substantially (Kubernetes' subtitle is aStatusDot+ text node;LinuxVMsuses different title text between its two occurrences; several action wrappers carry inline styles), so that refactor is unrelated to this bug and worth a separate issue.