fixed popup issue

This commit is contained in:
fuwaa 2022-08-22 15:17:43 +08:00
parent 2c6a630093
commit dbf66e6b42
No known key found for this signature in database
GPG key ID: 7CE0BF0D3175E2DC
3 changed files with 6 additions and 25 deletions

View file

@ -1,7 +0,0 @@
{
"commitizen": {
"name": "cz_conventional_commits",
"version": "0.0.1",
"tag_format": "v0.0.1"
}
}

View file

@ -1,5 +1,5 @@
{
"body": {
"ctrl-shift-,": "commandpalette:toggle"
"ctrl-k": "commandpalette:toggle"
}
}

View file

@ -7,8 +7,6 @@ const CommandPalette = (props) => {
const modal = useModal();
const { Dialog } = inkdrop.components.classes;
const searchRef = useRef(null);
const toggle = useCallback(() => {
modal.show();
logger.debug("Dialog was toggled!");
@ -21,23 +19,14 @@ const CommandPalette = (props) => {
return () => sub.dispose();
}, [toggle]);
// focus text box when dialog is shown
useLayoutEffect(() => {
document
.getElementById("cpInput")
.addEventListener("visibilitychange", onVisibilityChange);
return () =>
document
.getElementById("cpInput")
.removeEventListener("visibilitychange", onVisibilityChange);
setTimeout(() => {
const textbox = document.getElementById("cpInput");
textbox.focus();
}, 50);
});
const onVisibilityChange = () => {
if (element.classList.contains("visible")) {
document.getElementById("cpInput").focus();
}
};
return (
<Dialog {...modal.state} onBackdropClick={modal.close}>
<Dialog.Content className="commandpalette">
@ -50,7 +39,6 @@ const CommandPalette = (props) => {
spellCheck="false"
className="cpInput"
id="cpInput"
ref={searchRef}
/>
</div>
</div>