Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 3a8041d

Browse files
CaerusKaruThomasBurleson
authored andcommitted
fix(fxLayoutGap): add proper gaps for reverse dir
1 parent 0562fcc commit 3a8041d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/lib/flex/layout-gap/layout-gap.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ describe('layout-gap directive', () => {
208208
verifyCorrectMargin('column', 'margin-bottom');
209209
});
210210

211-
it('should apply margin-right for row-reverse layouts', () => {
212-
verifyCorrectMargin('row-reverse', 'margin-right');
211+
it('should apply margin-left for row-reverse layouts', () => {
212+
verifyCorrectMargin('row-reverse', 'margin-left');
213213
});
214214

215-
it('should apply margin-bottom for column-reverse layouts', () => {
216-
verifyCorrectMargin('column-reverse', 'margin-bottom');
215+
it('should apply margin-top for column-reverse layouts', () => {
216+
verifyCorrectMargin('column-reverse', 'margin-top');
217217
});
218218

219219
it('should remove obsolete margin and apply valid margin for layout changes', () => {
@@ -241,7 +241,7 @@ describe('layout-gap directive', () => {
241241
nodes = queryFor(fixture, 'span');
242242

243243
expectEl(nodes[0]).not.toHaveStyle({'margin-right': '8px'}, styler);
244-
expectEl(nodes[0]).toHaveStyle({'margin-bottom': '8px'}, styler);
244+
expectEl(nodes[0]).toHaveStyle({'margin-top': '8px'}, styler);
245245

246246

247247
// layout = row-reverse, use margin-right
@@ -250,7 +250,7 @@ describe('layout-gap directive', () => {
250250
nodes = queryFor(fixture, 'span');
251251

252252
expectEl(nodes[0]).not.toHaveStyle({'margin-bottom': '8px'}, styler);
253-
expectEl(nodes[0]).toHaveStyle({'margin-right': '8px'}, styler);
253+
expectEl(nodes[0]).toHaveStyle({'margin-left': '8px'}, styler);
254254
});
255255

256256
it('should recognize hidden elements when applying gaps', () => {

src/lib/flex/layout-gap/layout-gap.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,17 @@ export class LayoutGapDirective extends BaseFxDirective
246246

247247
switch (this._layout) {
248248
case 'column':
249-
case 'column-reverse':
250249
key = 'margin-bottom';
251250
break;
252-
case 'row' :
251+
case 'column-reverse':
252+
key = 'margin-top';
253+
break;
254+
case 'row':
255+
key = this._directionality.value === 'rtl' ? 'margin-left' : 'margin-right';
256+
break;
253257
case 'row-reverse':
258+
key = this._directionality.value === 'rtl' ? 'margin-right' : 'margin-left';
259+
break;
254260
default :
255261
key = this._directionality.value === 'rtl' ? 'margin-left' : 'margin-right';
256262
break;

0 commit comments

Comments
 (0)