Skip to content

Commit

Permalink
Open/close Operations Panel with ctrl + o
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Jan 6, 2023
1 parent 64c4fd5 commit f068225
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@
"eng",
"sourcetoconcepts",
"sourcemappings",
"upsert"
"upsert",
"Unmount",
"keydown"
],
"skipIfMatch": [
"http://[^s]*",
Expand Down
19 changes: 18 additions & 1 deletion src/components/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ const AuthenticationRequiredRoute = ({component: Component, ...rest}) => (
)

const App = props => {
const { openOperations, menuOpen, setMenuOpen, setOpenOperations } = React.useContext(OperationsContext);

// For recent history
setUpRecentHistory(props.history);
const { openOperations, menuOpen, setMenuOpen } = React.useContext(OperationsContext);

const setupHotJar = () => {
/*eslint no-undef: 0*/
const HID = window.HOTJAR_ID || process.env.HOTJAR_ID
Expand All @@ -69,10 +71,25 @@ const App = props => {
}
});

const myStateRef = React.useRef(openOperations);
const setMyState = data => {
myStateRef.current = data;
setOpenOperations(data);
};

const _listenKey = event => {
const isCtrlO = event.keyCode === 79 && event.ctrlKey;
if (isCtrlO) {
setMyState(!myStateRef.current)
}
};

React.useEffect(() => {
addLogoutListenerForAllTabs()
recordGAPageView()
setupHotJar()
document.body.addEventListener("keydown", _listenKey)
return () => document.body.removeEventListener("keydown", _listenKey)
}, [])

const isFHIR = isFHIRServer();
Expand Down

0 comments on commit f068225

Please sign in to comment.