Modal to directly navigate to an element
1 unresolved thread
1 unresolved thread
Compare changes
+ 37
− 3
@@ -45,6 +45,22 @@
@@ -53,11 +69,13 @@ import {
@@ -65,18 +83,26 @@ export default {
@@ -93,7 +119,15 @@ export default {
If you used a dedicated component for that, you may be able to set the focus in mounted ?
WDYT @erwanrouchet
It would probably be cleaner to have all of this in a separate component, but a modal may still be hidden when it is mounted, since it's only when the
v-model
becomestrue
that it actually is opened.The focus can be done by setting a Vue ref on the input with
<input ref="gotoInput" …>
, then callingthis.$refs.gotoInput.focus()
when the modal is opened (whenthis.gotoModal
becomestrue
). This is how we do it in other components like the filter bar.@erwanrouchet I tried exactly that, but it did not work in that case.
Maybe it is because of the search input that is triggered by
ctrl
+g
. I'll look further.