Skip to content

Commit 7fda0ef

Browse files
committed
fix: use uppercase resize trigger names based on material spec
1 parent f6ad4a1 commit 7fda0ef

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

packages/designer/src/builtin-simulator/bem-tools/border-resizing.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SimulatorContext } from '../context';
66
import { BuiltinSimulatorHost } from '../host';
77
import { OffsetObserver, Designer } from '../../designer';
88
import { Node } from '../../document';
9+
import { normalizeTriggers } from '../../utils/misc';
910

1011
@observer
1112
export default class BoxResizing extends Component<{ host: BuiltinSimulatorHost }> {
@@ -245,12 +246,14 @@ export class BoxResizingInstance extends Component<{
245246
triggerVisible = metadata.configure.advanced.getResizingHandlers(node.internalToShellNode());
246247
}
247248

249+
triggerVisible = normalizeTriggers(triggerVisible);
250+
248251
const baseSideClass = 'lc-borders lc-resize-side';
249252
const baseCornerClass = 'lc-borders lc-resize-corner';
250253

251254
return (
252255
<div>
253-
{triggerVisible.includes('n') && (
256+
{triggerVisible.includes('N') && (
254257
<div
255258
ref={(ref) => { this.outlineN = ref; }}
256259
className={classNames(baseSideClass, 'n')}
@@ -261,7 +264,7 @@ export class BoxResizingInstance extends Component<{
261264
}}
262265
/>
263266
)}
264-
{triggerVisible.includes('ne') && (
267+
{triggerVisible.includes('NE') && (
265268
<div
266269
ref={(ref) => { this.outlineNE = ref; }}
267270
className={classNames(baseCornerClass, 'ne')}
@@ -271,7 +274,7 @@ export class BoxResizingInstance extends Component<{
271274
}}
272275
/>
273276
)}
274-
{triggerVisible.includes('e') && (
277+
{triggerVisible.includes('E') && (
275278
<div
276279
className={classNames(baseSideClass, 'e')}
277280
ref={(ref) => { this.outlineE = ref; }}
@@ -282,7 +285,7 @@ export class BoxResizingInstance extends Component<{
282285
}}
283286
/>
284287
)}
285-
{triggerVisible.includes('se') && (
288+
{triggerVisible.includes('SE') && (
286289
<div
287290
ref={(ref) => { this.outlineSE = ref; }}
288291
className={classNames(baseCornerClass, 'se')}
@@ -292,7 +295,7 @@ export class BoxResizingInstance extends Component<{
292295
}}
293296
/>
294297
)}
295-
{triggerVisible.includes('s') && (
298+
{triggerVisible.includes('S') && (
296299
<div
297300
ref={(ref) => { this.outlineS = ref; }}
298301
className={classNames(baseSideClass, 's')}
@@ -303,7 +306,7 @@ export class BoxResizingInstance extends Component<{
303306
}}
304307
/>
305308
)}
306-
{triggerVisible.includes('sw') && (
309+
{triggerVisible.includes('SW') && (
307310
<div
308311
ref={(ref) => { this.outlineSW = ref; }}
309312
className={classNames(baseCornerClass, 'sw')}
@@ -313,7 +316,7 @@ export class BoxResizingInstance extends Component<{
313316
}}
314317
/>
315318
)}
316-
{triggerVisible.includes('w') && (
319+
{triggerVisible.includes('W') && (
317320
<div
318321
ref={(ref) => { this.outlineW = ref; }}
319322
className={classNames(baseSideClass, 'w')}
@@ -324,7 +327,7 @@ export class BoxResizingInstance extends Component<{
324327
}}
325328
/>
326329
)}
327-
{triggerVisible.includes('nw') && (
330+
{triggerVisible.includes('NW') && (
328331
<div
329332
ref={(ref) => { this.outlineNW = ref; }}
330333
className={classNames(baseCornerClass, 'nw')}

packages/designer/src/utils/misc.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ export function isDOMNodeVisible(domNode: Element, viewport: Viewport) {
2121
right <= width + nodeWidth
2222
);
2323
}
24+
25+
/**
26+
* normalize triggers
27+
* @param triggers
28+
*/
29+
export function normalizeTriggers(triggers: string[]) {
30+
return triggers.map((trigger: string) => trigger?.toUpperCase());
31+
}

0 commit comments

Comments
 (0)