Added delete key shortcut to select maps and tokens modal
This commit is contained in:
parent
8d85f6e347
commit
fa659bc80a
@ -46,13 +46,9 @@ function MapTiles({
|
||||
}
|
||||
}
|
||||
|
||||
let hasSelectedDefaultMap = false;
|
||||
for (let map of selectedMaps) {
|
||||
if (map.type === "default") {
|
||||
hasSelectedDefaultMap = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasSelectedDefaultMap = selectedMaps.some(
|
||||
(map) => map.type === "default"
|
||||
);
|
||||
|
||||
function mapToTile(map) {
|
||||
const isSelected = selectedMaps.includes(map);
|
||||
|
@ -33,16 +33,10 @@ function TokenTiles({
|
||||
const { databaseStatus } = useContext(DatabaseContext);
|
||||
const isSmallScreen = useMedia({ query: "(max-width: 500px)" });
|
||||
|
||||
let hasSelectedDefaultToken = false;
|
||||
let allTokensVisible = true;
|
||||
for (let token of selectedTokens) {
|
||||
if (token.type === "default") {
|
||||
hasSelectedDefaultToken = true;
|
||||
}
|
||||
if (token.hideInSidebar) {
|
||||
allTokensVisible = false;
|
||||
}
|
||||
}
|
||||
let hasSelectedDefaultToken = selectedTokens.some(
|
||||
(token) => token.type === "default"
|
||||
);
|
||||
let allTokensVisible = selectedTokens.every((token) => !token.hideInSidebar);
|
||||
|
||||
function tokenToTile(token) {
|
||||
const isSelected = selectedTokens.includes(token);
|
||||
|
@ -298,6 +298,15 @@ function SelectMapModal({
|
||||
if (key === "Control" || key === "Meta") {
|
||||
setSelectMode("multiple");
|
||||
}
|
||||
if (key === "Backspace" || key === "Delete") {
|
||||
// Selected maps and none are default
|
||||
if (
|
||||
selectedMapIds.length > 0 &&
|
||||
!selectedMaps.some((map) => map.type === "default")
|
||||
) {
|
||||
setIsMapsRemoveModalOpen(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyUp({ key }) {
|
||||
|
@ -170,6 +170,15 @@ function SelectTokensModal({ isOpen, onRequestClose }) {
|
||||
if (key === "Control" || key === "Meta") {
|
||||
setSelectMode("multiple");
|
||||
}
|
||||
if (key === "Backspace" || key === "Delete") {
|
||||
// Selected tokens and none are default
|
||||
if (
|
||||
selectedTokenIds.length > 0 &&
|
||||
!selectedTokens.some((token) => token.type === "default")
|
||||
) {
|
||||
setIsTokensRemoveModalOpen(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyUp({ key }) {
|
||||
|
Loading…
Reference in New Issue
Block a user