fix: ensure s and g shortcuts work on no selection (#3800)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Jakub Koralewski 2021-07-04 22:27:33 +02:00 committed by GitHub
parent 097362662d
commit ee64a7e264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 12 deletions

View File

@ -156,6 +156,7 @@ import {
getElementsWithinSelection,
getNormalizedZoom,
getSelectedElements,
hasBackground,
isOverScrollBars,
isSomeElementSelected,
} from "../scene";
@ -1582,19 +1583,24 @@ class App extends React.Component<AppProps, AppState> {
}
if (event.key === KEYS.G || event.key === KEYS.S) {
const selectedElements = getSelectedElements(
if (this.state.elementType === "selection") {
return;
}
if (
event.key === KEYS.G &&
(hasBackground(this.state.elementType) ||
getSelectedElements(
this.scene.getElements(),
this.state,
);
if (selectedElements.length) {
if (event.key === KEYS.G) {
).some((element) => hasBackground(element.type)))
) {
this.setState({ openPopup: "backgroundColorPicker" });
}
if (event.key === KEYS.S) {
this.setState({ openPopup: "strokeColorPicker" });
}
}
}
},
);

View File

@ -11,7 +11,7 @@ export const SHAPES = [
</svg>
),
value: "selection",
key: [KEYS.V, KEYS.S],
key: KEYS.V,
},
{
icon: (