mirror of
https://github.com/ryanamay/inkdrop-command-palette.git
synced 2024-09-20 01:40:34 +00:00
fixed popup issue
This commit is contained in:
parent
2c6a630093
commit
dbf66e6b42
3 changed files with 6 additions and 25 deletions
7
cz.json
7
cz.json
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"commitizen": {
|
||||
"name": "cz_conventional_commits",
|
||||
"version": "0.0.1",
|
||||
"tag_format": "v0.0.1"
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"body": {
|
||||
"ctrl-shift-,": "commandpalette:toggle"
|
||||
"ctrl-k": "commandpalette:toggle"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue