mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03:00
22 lines
693 B
JavaScript
22 lines
693 B
JavaScript
|
import wormhole from 'liquid-wormhole/transitions/wormhole';
|
||
|
|
||
|
// override liquid-wormhole's default `wormhole` transition to focus the first
|
||
|
// autofocus element after the transition and element swap happens
|
||
|
|
||
|
export default function () {
|
||
|
let newWormholeElement;
|
||
|
|
||
|
if (this.newElement) {
|
||
|
newWormholeElement = this.newElement.find('.liquid-wormhole-element:last-child');
|
||
|
}
|
||
|
|
||
|
return wormhole.apply(this, arguments).finally(() => {
|
||
|
if (this.newElement && newWormholeElement) {
|
||
|
let autofocusElem = newWormholeElement[0].querySelector('[autofocus]');
|
||
|
if (autofocusElem) {
|
||
|
autofocusElem.focus();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|