fix: color picker shortcuts not working when elements selected (#3817)

This commit is contained in:
David Luzar 2021-07-10 23:05:00 +02:00 committed by GitHub
parent 8787f3dc60
commit 0749d2c1f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1587,17 +1587,21 @@ class App extends React.Component<AppProps, AppState> {
} }
if (event.key === KEYS.G || event.key === KEYS.S) { if (event.key === KEYS.G || event.key === KEYS.S) {
if (this.state.elementType === "selection") { const selectedElements = getSelectedElements(
this.scene.getElements(),
this.state,
);
if (
this.state.elementType === "selection" &&
!selectedElements.length
) {
return; return;
} }
if ( if (
event.key === KEYS.G && event.key === KEYS.G &&
(hasBackground(this.state.elementType) || (hasBackground(this.state.elementType) ||
getSelectedElements( selectedElements.some((element) => hasBackground(element.type)))
this.scene.getElements(),
this.state,
).some((element) => hasBackground(element.type)))
) { ) {
this.setState({ openPopup: "backgroundColorPicker" }); this.setState({ openPopup: "backgroundColorPicker" });
} }