Skip to content
Merged
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
15 changes: 12 additions & 3 deletions app/javascript/alchemy_admin/components/elements_window.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SortableElements from "alchemy_admin/sortable_elements"
import { ElementEditor } from "alchemy_admin/components/element_editor"

class ElementsWindow extends HTMLElement {
#visible = true
Expand All @@ -15,9 +16,7 @@ class ElementsWindow extends HTMLElement {
this.toggle()
})
if (window.location.hash) {
document
.querySelector(window.location.hash)
?.trigger("FocusElementEditor.Alchemy")
this.focusElementEditor(window.location.hash)
}
SortableElements()
this.resize()
Expand Down Expand Up @@ -64,6 +63,16 @@ class ElementsWindow extends HTMLElement {
}
}

// Focus element editor and element in preview if URL contains hash to element editor.
// The link is coming from the assignment view when showing assigned files or pictures.
focusElementEditor(dom_id) {
const el = document.querySelector(dom_id)

if (el instanceof ElementEditor) {
el.focusElement() && el.focusElementPreview()
}
}

get collapseButton() {
return this.querySelector("#collapse-all-elements-button")
}
Expand Down
Loading