add admin UX quick wins: nav guard, block descriptions, input labels
All checks were successful
deploy / deploy (push) Successful in 1m16s
All checks were successful
deploy / deploy (push) Successful in 1m16s
- rename "Providers" to "Print providers" in sidebar (#110) - add LiveView navigation guard to EditorKeyboard hook — intercepts link clicks in capture phase when editor has unsaved changes (#103) - add description field to all 26 block types, shown as subtitle in block picker; filter searches descriptions too (#104) - add visible column headers (Label / Path) and proper sr-only labels with for attributes on nav editor inputs (#106) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -662,6 +662,24 @@ const EditorKeyboard = {
|
||||
}
|
||||
window.addEventListener("beforeunload", this._beforeUnload)
|
||||
|
||||
// Intercept LiveView navigation clicks when editor has unsaved changes.
|
||||
// Uses capture phase to fire before LiveView's own click handler.
|
||||
this._clickGuard = (e) => {
|
||||
if (this.el.dataset.dirty !== "true") return
|
||||
|
||||
const link = e.target.closest("a[data-phx-link]")
|
||||
if (!link) return
|
||||
|
||||
// Don't block clicks inside the editor itself (e.g. block controls)
|
||||
if (this.el.contains(link)) return
|
||||
|
||||
if (!window.confirm("You have unsaved changes that will be lost. Leave anyway?")) {
|
||||
e.preventDefault()
|
||||
e.stopImmediatePropagation()
|
||||
}
|
||||
}
|
||||
document.addEventListener("click", this._clickGuard, true)
|
||||
|
||||
const prefix = this.el.dataset.eventPrefix || ""
|
||||
this._keydown = (e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "z") {
|
||||
@@ -678,6 +696,7 @@ const EditorKeyboard = {
|
||||
|
||||
destroyed() {
|
||||
window.removeEventListener("beforeunload", this._beforeUnload)
|
||||
document.removeEventListener("click", this._clickGuard, true)
|
||||
document.removeEventListener("keydown", this._keydown)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user