Skip to content

Commit

Permalink
After second review
Browse files Browse the repository at this point in the history
Made changes as suggested.
  • Loading branch information
przemyslawturek committed Nov 16, 2023
1 parent a71b472 commit cac4cdf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/InstancesList/InstancesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
Checkbox,
MenuSection,
Select,
checkScope,
HasCommand,
MCLPagingTypes,
TextLink,
Expand All @@ -56,6 +55,7 @@ import {
marshalInstance,
omitFromArray,
isTestEnv,
handleKeyCommand,
buildSingleItemQuery,
isUserInConsortiumMode,
} from '../../utils';
Expand Down Expand Up @@ -1173,18 +1173,20 @@ class InstancesList extends React.Component {
const shortcuts = [
{
name: 'new',
handler: (e) => {
const nodeName = e.target?.nodeName || '';
const isEditTextField = (nodeName === 'TEXTAREA') || (nodeName === 'INPUT');
if (isEditTextField) return;

handler: handleKeyCommand(() => {
if (stripes.hasPerm('ui-inventory.instance.create')) {
this.openCreateInstance();
}
},
}),
},
];

const checkScope = () => {
const ignoreElements = ['TEXTAREA', 'INPUT'];

return !ignoreElements.includes(document.activeElement.tagName);
};

return (
<HasCommand
commands={shortcuts}
Expand Down

0 comments on commit cac4cdf

Please sign in to comment.