Skip to content

Commit 80f9965

Browse files
committed
Focus the input element after clicking the Code button or its tabs
1 parent 355e9a9 commit 80f9965

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

web_src/js/features/repo-common.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {queryElems, type DOMEvent} from '../utils/dom.ts';
1+
import {addDelegatedEventListener, queryElems, type DOMEvent} from '../utils/dom.ts';
22
import {POST} from '../modules/fetch.ts';
33
import {showErrorToast} from '../modules/toast.ts';
44
import {sleep} from '../utils.ts';
@@ -141,6 +141,12 @@ function initClonePanelButton(btn: HTMLButtonElement) {
141141
interactive: true,
142142
hideOnClick: true,
143143
arrow: false,
144+
onMount: (instance) => { // focus input on open and on tab click
145+
instance.popper.querySelector<HTMLInputElement>('.js-clone-url')?.focus();
146+
addDelegatedEventListener(instance.popper, 'click', '.clone-panel-tab .item', () => {
147+
instance.popper.querySelector<HTMLInputElement>('.js-clone-url')?.focus();
148+
});
149+
},
144150
});
145151
}
146152

0 commit comments

Comments
 (0)