File tree Expand file tree Collapse file tree 2 files changed +431
-3
lines changed
app/javascript/alchemy_admin/components
spec/javascript/alchemy_admin/components Expand file tree Collapse file tree 2 files changed +431
-3
lines changed Original file line number Diff line number Diff line change 11import SortableElements from "alchemy_admin/sortable_elements"
2+ import { ElementEditor } from "alchemy_admin/components/element_editor"
23
34class ElementsWindow extends HTMLElement {
45 #visible = true
@@ -15,9 +16,7 @@ class ElementsWindow extends HTMLElement {
1516 this . toggle ( )
1617 } )
1718 if ( window . location . hash ) {
18- document
19- . querySelector ( window . location . hash )
20- ?. trigger ( "FocusElementEditor.Alchemy" )
19+ this . focusElementEditor ( window . location . hash )
2120 }
2221 SortableElements ( )
2322 this . resize ( )
@@ -64,6 +63,16 @@ class ElementsWindow extends HTMLElement {
6463 }
6564 }
6665
66+ // Focus element editor and element in preview if URL contains hash to element editor.
67+ // The link is coming from the assignment view when showing assigned files or pictures.
68+ focusElementEditor ( dom_id ) {
69+ const el = document . querySelector ( dom_id )
70+
71+ if ( el instanceof ElementEditor ) {
72+ el . focusElement ( ) && el . focusElementPreview ( )
73+ }
74+ }
75+
6776 get collapseButton ( ) {
6877 return this . querySelector ( "#collapse-all-elements-button" )
6978 }
You can’t perform that action at this time.
0 commit comments