Skip to content

Commit 66703b4

Browse files
Music blocks rtl fixes (#10601)
* Gallery arrow key nav in RTL languages * RTL Layout issues in Sound Effect editor
1 parent 95f7f2c commit 66703b4

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

pxtlib/melody-editor/melodyGallery.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ namespace pxtmelody {
6262
return;
6363
}
6464
const [x, y] = this.selectedColRow;
65+
const arrowToSelection = pxt.Util.isUserLanguageRtl() ? "ArrowRight" : "ArrowLeft";
66+
const arrowToPreview = pxt.Util.isUserLanguageRtl() ? "ArrowLeft" : "ArrowRight";
6567
switch(e.code) {
6668
case "ArrowUp": {
6769
this.selectedColRow = [x, Math.max(0, y - 1)];
@@ -71,11 +73,11 @@ namespace pxtmelody {
7173
this.selectedColRow = [x, Math.min(this.selectionButtons.length - 1, y + 1)];
7274
break;
7375
}
74-
case "ArrowLeft": {
76+
case arrowToSelection: {
7577
this.selectedColRow = [Math.max(0, x - 1), y];
7678
break;
7779
}
78-
case "ArrowRight": {
80+
case arrowToPreview: {
7981
// Only two columns.
8082
this.selectedColRow = [Math.min(1, x + 1), y];
8183
break;

react-common/components/controls/DraggableGraph.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ export const DraggableGraph = (props: DraggableGraphProps) => {
173173
!isNotLast && getValue(index - 1) > getValue(index)
174174
);
175175

176+
const textAnchor = (isNotLast !== pxt.Util.isUserLanguageRtl()) ? "start" : "end"
177+
176178
return <g key={index} className="draggable-graph-column">
177179
{isNotLast &&
178180
<path
@@ -216,7 +218,7 @@ export const DraggableGraph = (props: DraggableGraphProps) => {
216218
className="common-draggable-graph-text"
217219
x={isNotLast ? x + unit * 2 : x - unit}
218220
y={shouldFlipLabel ? y + unit * 2 : Math.max(y - unit, unit)}
219-
textAnchor={isNotLast ? "start" : "end"}
221+
textAnchor={textAnchor}
220222
fontSize={unit}>
221223
{Math.round(getValue(index)) + (valueUnits || "")}
222224
</text>

theme/soundeffecteditor.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@
202202
}
203203
}
204204

205+
.rtl .common-button.sound-effect-play-button {
206+
.fas.fa-play, .fas.fa-stop {
207+
margin: 0 0.25rem 0 0;
208+
}
209+
}
210+
205211
.common-button.sound-effect-play-button:focus-visible {
206212
outline: 3px solid var(--pxt-focus-border);
207213
outline-offset: 3px;

webapp/src/components/soundEffectEditor/SoundGallery.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@ export const SoundGallery = (props: SoundGalleryProps) => {
4343
next: number,
4444
current: number,
4545
e: React.KeyboardEvent<HTMLElement>) => {
46+
const arrowToSelection = pxt.Util.isUserLanguageRtl() ? "ArrowRight" : "ArrowLeft";
47+
const arrowToPreview = pxt.Util.isUserLanguageRtl() ? "ArrowLeft" : "ArrowRight";
4648
switch(e.code) {
4749
case "ArrowDown":
4850
selectedCoord.current.row = next;
4951
break;
5052
case "ArrowUp":
5153
selectedCoord.current.row = prev;
5254
break;
53-
case "ArrowLeft":
55+
case arrowToSelection:
5456
selectedCoord.current.col = "select";
5557
break;
56-
case "ArrowRight":
58+
case arrowToPreview:
5759
selectedCoord.current.col = "preview";
5860
break;
5961
case "Space":

0 commit comments

Comments
 (0)