react-x11 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-x11",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "react renderer with X11 as a target",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -83,7 +83,7 @@
83
83
  "node": ">=20.19"
84
84
  },
85
85
  "dependencies": {
86
- "ntk": "^8.4.0",
86
+ "ntk": "^8.5.0",
87
87
  "react-reconciler": "^0.33.0",
88
88
  "yoga-layout": "^3.2.1"
89
89
  },
@@ -59,7 +59,12 @@ const h = React.createElement;
59
59
  const MENU_ITEM_PAD = 8;
60
60
  const menuRowHeight = (fontSize) => capBand(fontSize) + MENU_ITEM_PAD * 2;
61
61
 
62
- const MENU_SEPARATOR_HEIGHT = 7;
62
+ // A separator is the hairline plus the air that makes it a division rather
63
+ // than a row with a line through it — the two groups it stands between have
64
+ // to read as apart, and at three pixels a side the line just crowds the
65
+ // labels above and below it.
66
+ const MENU_SEPARATOR_PAD = 5;
67
+ const MENU_SEPARATOR_HEIGHT = MENU_SEPARATOR_PAD * 2 + 1;
63
68
 
64
69
  const MENU_MIN_WIDTH = 140;
65
70
 
@@ -76,28 +81,47 @@ const MENU_PAD = 4;
76
81
  // borders on its *controls* does not mean a 2px outline around every menu.
77
82
  const MENU_BORDER = 1;
78
83
 
79
- // How far a bar item's pill sits inside the bar, taken out of its padding so
80
- // the bar's height does not change. The strip carries the same inset at its
81
- // two ends: a pill that starts in the window's own corner reads as part of
82
- // the frame rather than as something on a strip, and the first menu is the
83
- // one every pointer arrives at.
84
- const BAR_INSET = 3;
85
- // the gap between two pills, split between them
86
- const BAR_GAP = 1;
87
-
88
84
  // A bar item wears the same pill as a row in the menu it opens, so it takes
89
85
  // the row's padding rather than numbers of its own: a title packed tighter
90
86
  // than its own first row is the tell that the two were measured separately.
91
87
  // Vertically that is `MENU_ITEM_PAD` exactly — same padding, same `capTrim`
92
- // text — which makes the pill `menuRowHeight` tall, and the bar that much
93
- // taller for it.
88
+ // text — which makes the pill `menuRowHeight` tall and the strip exactly
89
+ // that: a menu bar is one row, and its highlight fills it top to bottom the
90
+ // way a real one does. Inset the pill instead and the bar is a row plus two
91
+ // margins tall, with a highlight floating in a band of leftover strip.
92
+ //
93
+ // Horizontally it takes a little more, and the number is measured rather
94
+ // than argued: the bar this one is imitating leaves 22px between the ink of
95
+ // two titles, so that is what a title's own padding and its neighbour's have
96
+ // to add up to. A row's label in a menu with a check column is
97
+ // `MENU_ITEM_PAD + MENU_GUTTER` from the pill's edge anyway, so the row's own
98
+ // padding would read as the cramped one here — a title has no column to sit
99
+ // past, but it does sit shoulder to shoulder with the next title.
94
100
  //
95
- // Horizontally it takes a little more. A row's label is not `MENU_ITEM_PAD`
96
- // from the pill's edge but a whole `MENU_GUTTER` in, past the check column,
97
- // so matching the row's padding here would read as the cramped one: on a
98
- // strip the pills sit shoulder to shoulder, with nothing but that padding
99
- // between one label and the next.
100
- const BAR_ITEM_PAD_X = MENU_ITEM_PAD + 4;
101
+ const BAR_ITEM_PAD_X = MENU_ITEM_PAD + 3;
102
+
103
+ // The pill is wider than the item that owns it. Measured off the same bar:
104
+ // its highlight runs 16px past the ink of the title it belongs to, which is
105
+ // five past the halfway line between that title and the next — so a lit
106
+ // title reaches *into* both neighbours' halves of the strip rather than
107
+ // stopping politely at the boundary. It reads as one object sitting on the
108
+ // bar; a pill that stops at the midpoint reads as one cell of a table that
109
+ // happens to be filled in.
110
+ //
111
+ // Drawn, not laid out. The item box still tiles the strip, so the 22px
112
+ // between two titles is still two paddings and the pointer still belongs to
113
+ // exactly one item everywhere along the bar. Widening the boxes to the size
114
+ // of the pill instead would overlap them by ten pixels, and then the last
115
+ // five of a title's own highlight would open its neighbour's menu.
116
+ const BAR_PILL_BLEED = 5;
117
+
118
+ // What is left of the strip at its two ends, before the first pill and after
119
+ // the last: a highlight cut off square by the window's edge is the one place
120
+ // a pill has no room to be a pill. Measured like the rest — a native bar
121
+ // leaves five — and the strip's padding is that plus the bleed, since the
122
+ // pill starts before its item does.
123
+ const BAR_END_INSET = 5;
124
+ const BAR_END_PAD = BAR_END_INSET + BAR_PILL_BLEED;
101
125
 
102
126
  // The bar entry that stands for the titles that did not fit. A symbol rather
103
127
  // than a `label`, because it is the one entry on the bar the application did
@@ -119,9 +143,29 @@ const OVERFLOW_KEY = '\0menubar-overflow';
119
143
  // way (`movingToward`), so this is a matter of taste rather than of reach.
120
144
  const SUBMENU_GAP = 0;
121
145
 
122
- const MENU_GUTTER = 24; // room for the check column
123
- // what a self-drawing icon gets to fill, inside that column's 16px
146
+ // what a self-drawing icon gets to fill
124
147
  const MENU_ICON_SIZE = 12;
148
+ // The air between that mark and the label it belongs to. A mark set against
149
+ // its label with a pixel or two to spare reads as part of the word rather
150
+ // than as a column of its own — but the column is an indent every label in
151
+ // the menu pays for, so it is the smallest gap that still reads as one:
152
+ // enough to separate two things, less than the space between two words.
153
+ const MENU_ICON_GAP = 6;
154
+ // The check column: the mark's own box plus that gap. The mark starts at the
155
+ // row's padding — flush with where a label starts in a menu that has no
156
+ // column at all — so the whole of the column's width is the space after it.
157
+ const MENU_GUTTER = MENU_ICON_SIZE + MENU_ICON_GAP;
158
+
159
+ // Menu text sits a step above the body weight. A menu is read in glances
160
+ // rather than in sentences — a title on a strip, a row under the pointer —
161
+ // and the native ones are all set a shade heavier for it. Where the face has
162
+ // a medium this picks it; where it has only a regular and a bold, 500 is
163
+ // nearer the regular and nothing changes, which is the right failure.
164
+ //
165
+ // Every label measured for a popup's width is measured at this weight too
166
+ // (`measureLabel` takes it), since a menu sized in regular for rows drawn in
167
+ // medium is a menu whose own labels run into its shortcuts.
168
+ const MENU_TEXT_WEIGHT = 500;
125
169
 
126
170
  const MENU_SHORTCUT_GAP = 24;
127
171
  // menus size to their content rather than scrolling, so a page is a fixed
@@ -138,6 +182,37 @@ function menuListHeight(items, fontSize) {
138
182
  return body + (MENU_PAD + MENU_BORDER) * 2;
139
183
  }
140
184
 
185
+ /**
186
+ * The width of this menu's check column, which is `0` for a menu with
187
+ * nothing to draw in it.
188
+ *
189
+ * The question is asked of the level rather than of the row — one mark
190
+ * anywhere in a menu indents every label in it, which is what puts the
191
+ * labels in a column of their own — and what counts is what is *drawn*, not
192
+ * what could be. A checkbox that is off draws nothing, so a menu of unticked
193
+ * toggles is a menu of plain commands as far as the eye is concerned, and it
194
+ * gets the plain menu's left edge.
195
+ *
196
+ * The cost is the one every toolkit reserving this column is avoiding:
197
+ * ticking the first item in such a menu moves its labels sideways. That is
198
+ * the trade this codebase makes deliberately — an indent on every menu with
199
+ * a toggle anywhere in it, paid by every label in it, buys stillness in the
200
+ * one frame where something is ticked. A menu that already has a mark keeps
201
+ * the column whatever happens to the rest, so the movement is once at the
202
+ * boundary rather than on every tick.
203
+ *
204
+ * `toggleState` is dbusmenu's three-state one: `-1` draws a dash and counts,
205
+ * `0` draws nothing and does not. A separator answers for nothing either way,
206
+ * since it spans the row.
207
+ */
208
+ function menuGutter(items) {
209
+ const wanted = visibleItems(items).some(
210
+ (item) =>
211
+ !isSeparator(item) && (toggleMark(item) != null || item.icon != null),
212
+ );
213
+ return wanted ? MENU_GUTTER : 0;
214
+ }
215
+
141
216
  /** Widest label + shortcut, measured, so the popup can be sized up front. */
142
217
  function menuListWidth(node, items, fontSize) {
143
218
  let widest = 0;
@@ -145,20 +220,23 @@ function menuListWidth(node, items, fontSize) {
145
220
  if (isSeparator(item)) continue;
146
221
  const label = measureLabel(node, item.label ?? '', {
147
222
  size: fontSize,
223
+ weight: MENU_TEXT_WEIGHT,
148
224
  }).width;
149
225
  const accelerator = formatShortcut(item.shortcut);
150
226
  const shortcut = accelerator
151
- ? measureLabel(node, accelerator, { size: fontSize }).width +
152
- MENU_SHORTCUT_GAP
227
+ ? measureLabel(node, accelerator, {
228
+ size: fontSize,
229
+ weight: MENU_TEXT_WEIGHT,
230
+ }).width + MENU_SHORTCUT_GAP
153
231
  : 0;
154
232
  widest = Math.max(widest, label + shortcut);
155
233
  }
156
234
  return Math.max(
157
235
  MENU_MIN_WIDTH,
158
236
  Math.ceil(widest) +
159
- MENU_GUTTER +
237
+ menuGutter(items) +
160
238
  (MENU_PAD + MENU_BORDER) * 2 +
161
- MENU_ITEM_PAD +
239
+ MENU_ITEM_PAD * 2 +
162
240
  2,
163
241
  );
164
242
  }
@@ -169,13 +247,15 @@ function menuListWidth(node, items, fontSize) {
169
247
  * `menuListWidth` so the two cannot drift.
170
248
  */
171
249
  function barItemWidth(node, label, fontSize) {
172
- const text = measureLabel(node, label ?? '', { size: fontSize }).width;
173
- return Math.ceil(text) + (BAR_ITEM_PAD_X + BAR_GAP) * 2;
250
+ const text = measureLabel(node, label ?? '', {
251
+ size: fontSize,
252
+ weight: MENU_TEXT_WEIGHT,
253
+ }).width;
254
+ return Math.ceil(text) + BAR_ITEM_PAD_X * 2;
174
255
  }
175
256
 
176
257
  /** The same, for the chevron: an icon box where a title has its label. */
177
- const barOverflowWidth = (fontSize) =>
178
- iconSize(fontSize) + (BAR_ITEM_PAD_X + BAR_GAP) * 2;
258
+ const barOverflowWidth = (fontSize) => iconSize(fontSize) + BAR_ITEM_PAD_X * 2;
179
259
 
180
260
  /**
181
261
  * How many titles the bar can paint, and therefore where it is cut. The rest
@@ -195,7 +275,7 @@ const barOverflowWidth = (fontSize) =>
195
275
  */
196
276
  function barCut(node, menus, fontSize, width) {
197
277
  const widths = menus.map((menu) => barItemWidth(node, menu.label, fontSize));
198
- const inner = width - (BAR_INSET - BAR_GAP) * 2;
278
+ const inner = width - BAR_END_PAD * 2;
199
279
  const total = widths.reduce((sum, w) => sum + w, 0);
200
280
  if (total <= inner) return menus.length;
201
281
  const room = inner - barOverflowWidth(fontSize);
@@ -314,6 +394,10 @@ function MenuRow({
314
394
  onMove,
315
395
  onSelect,
316
396
  fontSize,
397
+ // The width of the level's check column — the same number the popup was
398
+ // sized with, passed down rather than asked of the item, since a row with
399
+ // no mark of its own still keeps the column its neighbours need.
400
+ gutter,
317
401
  nodeRef,
318
402
  }) {
319
403
  const theme = useTheme();
@@ -369,7 +453,6 @@ function MenuRow({
369
453
  alignItems: 'center',
370
454
  paddingLeft: MENU_ITEM_PAD,
371
455
  paddingRight: MENU_ITEM_PAD,
372
- cursor: dim ? undefined : 'pointer',
373
456
  // A pill inside the sheet: the row is inset from the popup edge by
374
457
  // the list's padding, and rounded so that its corner and the sheet's
375
458
  // share a centre — the two curves are then one shape rather than two
@@ -397,21 +480,37 @@ function MenuRow({
397
480
  : { ':active': { backgroundColor: theme.accentActive } }),
398
481
  },
399
482
  },
483
+ gutter > 0 &&
484
+ h(
485
+ 'box',
486
+ {
487
+ // The mark sits at the head of the column and the gap is what
488
+ // follows it, rather than the column centring its box and leaving
489
+ // half the gap on either side: the label is the thing that has to
490
+ // stand clear, and the row's own padding already spaces the mark.
491
+ style: { width: gutter, alignItems: 'flex-start' },
492
+ },
493
+ gutterMark(item, { color: rowInk, fontSize }),
494
+ ),
400
495
  h(
401
- 'box',
402
- { style: { width: MENU_GUTTER - MENU_ITEM_PAD, alignItems: 'center' } },
403
- gutterMark(item, { color: rowInk, fontSize }),
496
+ 'text',
497
+ { style: [capTrim, { fontSize, fontWeight: MENU_TEXT_WEIGHT }] },
498
+ item.label,
404
499
  ),
405
- h('text', { style: [capTrim, { fontSize }] }, item.label),
406
500
  h('box', { style: { flexGrow: 1 } }),
407
- // The accelerator and the chevron are quieter than the label at rest and
408
- // rise with the row when it is chosen — so on an active row they say
409
- // nothing and take what the row set.
501
+ // The accelerator is quieter than the label at rest and rises with the
502
+ // row when it is chosen — so on an active row it says nothing and takes
503
+ // what the row set. A shortcut is a second way to do what the label
504
+ // already says; the chevron below it is not, and keeps the row's ink.
410
505
  accelerator &&
411
506
  h(
412
507
  'text',
413
508
  {
414
- style: [capTrim, { fontSize }, !active && { color: theme.textMuted }],
509
+ style: [
510
+ capTrim,
511
+ { fontSize, fontWeight: MENU_TEXT_WEIGHT },
512
+ !active && { color: theme.textMuted },
513
+ ],
415
514
  },
416
515
  accelerator,
417
516
  ),
@@ -424,7 +523,9 @@ function MenuRow({
424
523
  // stands as tall as its box, so `MENU_ICON_SIZE` would put an arrow
425
524
  // beside the label taller than the label.
426
525
  size: capBand(fontSize),
427
- style: !active && { color: theme.textMuted },
526
+ // no `color`: the arrow is the row saying it has more behind it, as
527
+ // much a part of the entry as its label, and a muted one reads as a
528
+ // row that is half disabled rather than one with a submenu
428
529
  }),
429
530
  );
430
531
  }
@@ -463,6 +564,9 @@ function MenuLevel({
463
564
  }) {
464
565
  const theme = useTheme();
465
566
  const items = levelItems(rootItems, path, depth);
567
+ // one answer for the level, so every row indents by the same amount the
568
+ // popup was measured with
569
+ const gutter = menuGutter(items);
466
570
  const active = path[depth] ?? -1;
467
571
  const childItems = visibleItems(items[active]?.items);
468
572
  const childOpen = path.length > depth + 1 && childItems.length > 0;
@@ -621,6 +725,7 @@ function MenuLevel({
621
725
  item,
622
726
  state: rowState(index, active, handedOn),
623
727
  fontSize,
728
+ gutter,
624
729
  nodeRef: index === active ? activeRowRef : undefined,
625
730
  onHover: (ev) => hover(index, ev),
626
731
  onMove: (ev) => move(index, ev),
@@ -902,6 +1007,11 @@ export function MenuBar({
902
1007
  const theme = useTheme();
903
1008
  const rtl = useDirection() === 'rtl';
904
1009
  const [openIndex, setOpenIndex] = useState(-1);
1010
+ // The pointer's title, tracked here rather than left to a `:hover` block,
1011
+ // because the thing that lights up is no longer the node the pointer is
1012
+ // over: the pill is a child that reaches past its own item, and a state
1013
+ // block only ever answers for the node it is written on.
1014
+ const [hoverIndex, setHoverIndex] = useState(-1);
905
1015
  const [rect, setRect] = useState(null);
906
1016
  const [path, setPath] = useState([]);
907
1017
  const refs = useRef([]);
@@ -1120,8 +1230,8 @@ export function MenuBar({
1120
1230
  flexDirection: 'row',
1121
1231
  alignItems: 'center',
1122
1232
  backgroundColor: theme.surfaceHover,
1123
- paddingLeft: BAR_INSET - BAR_GAP,
1124
- paddingRight: BAR_INSET - BAR_GAP,
1233
+ paddingLeft: BAR_END_PAD,
1234
+ paddingRight: BAR_END_PAD,
1125
1235
  // `scroll` is what makes a box report its viewport, and the clip
1126
1236
  // that comes with it is wanted in its own right: it is what holds
1127
1237
  // the one frame before the first measurement — and any bar whose
@@ -1172,10 +1282,17 @@ export function MenuBar({
1172
1282
  onMouseDown: () =>
1173
1283
  openIndex === index ? close() : openMenu(index, 'pointer'),
1174
1284
  onMouseEnter: () => {
1285
+ setHoverIndex(index);
1175
1286
  if (openIndex >= 0 && openIndex !== index) {
1176
1287
  openMenu(index, 'pointer');
1177
1288
  }
1178
1289
  },
1290
+ onMouseLeave: () => {
1291
+ // the index rather than -1 unconditionally: the pointer reaches
1292
+ // the next title before this one hears it left, and clearing
1293
+ // then would put the bar back to nothing lit for a frame
1294
+ setHoverIndex((current) => (current === index ? -1 : current));
1295
+ },
1179
1296
  // read live: by the time a hand-off blurs this item, the item
1180
1297
  // taking over has already claimed the bar
1181
1298
  onBlur: () => {
@@ -1226,33 +1343,14 @@ export function MenuBar({
1226
1343
  },
1227
1344
  style: [
1228
1345
  {
1229
- cursor: 'pointer',
1230
1346
  paddingLeft: BAR_ITEM_PAD_X,
1231
1347
  paddingRight: BAR_ITEM_PAD_X,
1232
- // The same pill the rows inside the menu wear, at the same
1233
- // radius: the bar item and the first row of the menu it opens
1234
- // are one gesture, and a square title over rounded rows reads
1235
- // as two widgets that have not met.
1236
- //
1237
- // The margin is what a radius needs to be seen — a rounded
1238
- // rect flush against the strip's own edges reads as a cut
1239
- // corner rather than a pill. It sits *outside* the padding, so
1240
- // the bar is a menu row plus its two insets tall: the item and
1241
- // the row below it are then the same pill in the same size,
1242
- // which is the whole point of giving the bar one.
1243
- marginTop: BAR_INSET,
1244
- marginBottom: BAR_INSET,
1245
- marginLeft: BAR_GAP,
1246
- marginRight: BAR_GAP,
1348
+ // No vertical margin: the pill fills the strip, which is a
1349
+ // menu row tall and nothing more. The item and the first row
1350
+ // of the menu it opens are then the same pill in the same
1351
+ // size, which is the whole point of giving the bar one.
1247
1352
  paddingTop: MENU_ITEM_PAD,
1248
1353
  paddingBottom: MENU_ITEM_PAD,
1249
- borderRadius: rowRadius(theme, MENU_BORDER, MENU_PAD),
1250
- backgroundColor:
1251
- barState === 'active'
1252
- ? theme.hoverBackground
1253
- : barState === 'path'
1254
- ? theme.surfaceActive
1255
- : undefined,
1256
1354
  // No ring while this item's menu is up. Walking the bar with
1257
1355
  // the arrow keys opens each menu as it arrives, so the item is
1258
1356
  // already inverted with a menu hanging off it — a ring on top
@@ -1267,16 +1365,40 @@ export function MenuBar({
1267
1365
  // said once for whichever of the two the title turns out to be
1268
1366
  color: barState === 'active' ? theme.hoverText : theme.text,
1269
1367
  },
1270
- // Only while this menu is shut, as in `Select`: an open one is
1271
- // already showing the answer, and a state block would outrank
1272
- // the base colour that says so. The menu opens on the release,
1273
- // so `:active` is the whole of the answer to a held press.
1274
- openIndex !== index && {
1275
- ':hover': { backgroundColor: theme.surface },
1276
- ':active': { backgroundColor: theme.surfaceActive },
1277
- },
1278
1368
  ],
1279
1369
  },
1370
+ // The pill, drawn before the title so the title is drawn on it. It
1371
+ // is a box of its own rather than this item's background because it
1372
+ // is wider than this item: `BAR_PILL_BLEED` past both edges, which
1373
+ // is where a native bar's highlight ends (see the constant). Only
1374
+ // while it has a colour to be — nothing at rest, since the strip
1375
+ // under it is already that colour.
1376
+ //
1377
+ // Hover is the state that used to be a `:hover` block here and is
1378
+ // now `hoverIndex`, and only while this menu is shut: an open one is
1379
+ // already showing the answer, and the hover colour would outrank the
1380
+ // base colour that says so.
1381
+ (barState || hoverIndex === index) &&
1382
+ h('box', {
1383
+ style: {
1384
+ position: 'absolute',
1385
+ left: -BAR_PILL_BLEED,
1386
+ right: -BAR_PILL_BLEED,
1387
+ top: 0,
1388
+ bottom: 0,
1389
+ // the same radius the rows inside the menu wear: the bar item
1390
+ // and the first row of the menu it opens are one gesture, and
1391
+ // a square title over rounded rows reads as two widgets that
1392
+ // have not met
1393
+ borderRadius: rowRadius(theme, MENU_BORDER, MENU_PAD),
1394
+ backgroundColor:
1395
+ barState === 'active'
1396
+ ? theme.hoverBackground
1397
+ : barState === 'path'
1398
+ ? theme.surfaceActive
1399
+ : theme.surface,
1400
+ },
1401
+ }),
1280
1402
  overflow
1281
1403
  ? h(Icon, {
1282
1404
  // The set's own overflow mark, rather than the `»` Qt and
@@ -1288,7 +1410,11 @@ export function MenuBar({
1288
1410
  name: 'moreVertical',
1289
1411
  size: iconSize(fontSize),
1290
1412
  })
1291
- : h('text', { style: [capTrim, { fontSize }] }, menu.label),
1413
+ : h(
1414
+ 'text',
1415
+ { style: [capTrim, { fontSize, fontWeight: MENU_TEXT_WEIGHT }] },
1416
+ menu.label,
1417
+ ),
1292
1418
  );
1293
1419
  }),
1294
1420
  openIndex >= 0 &&
@@ -131,7 +131,6 @@ function Option({
131
131
  justifyContent: 'center',
132
132
  paddingLeft: ITEM_PAD_LEFT,
133
133
  paddingRight: ITEM_PAD_RIGHT,
134
- cursor: 'pointer',
135
134
  // the menus' pill, for the same reason and by the same rule: an
136
135
  // option list and a menu are one surface with rows in it, and two
137
136
  // shapes for that would only say the widgets were written apart
@@ -165,18 +165,27 @@ export function measureLabel(node, text, style) {
165
165
  // exactly the kind of error that turns into an ellipsis on the longest
166
166
  // label in the menu (src/scale.js).
167
167
  const s = node?.scale ?? 1;
168
+ // The face **this node inherits**, not the literal `sans-serif` at whatever
169
+ // the defaults are: the labels these popups are sized around name no type
170
+ // of their own, so the one they are drawn in is the one that cascades down
171
+ // to them. Measuring in a different face is measuring the wrong label — a
172
+ // menu sized in sans-serif for a row that paints in a wider mono is a menu
173
+ // whose own options wrap.
174
+ //
175
+ // Which is every property that changes a glyph's advance, not the family
176
+ // alone. `fontVariationSettings` is the one that bites: a tree that sets
177
+ // `{ opsz: 17 }` on its window — the text cut of a variable face, wider
178
+ // than the display cut most files default to — draws every row in it and
179
+ // used to measure none, and the popup came out narrow enough to wrap its
180
+ // own labels. An explicit `style` still wins, since a caller that names a
181
+ // face is measuring something it is about to draw in that face.
182
+ const inherited = node?.inheritedTextStyle;
168
183
  const layout = fonts.layout(String(text), {
169
- // The face **this node inherits**, not the literal `sans-serif`: the
170
- // labels these popups are sized around name no family of their own, so
171
- // the one they are drawn in is the palette's. Measuring in a different
172
- // face is measuring the wrong label — a menu sized in sans-serif for a
173
- // row that paints in a wider mono is a menu whose own options wrap.
174
- family: style?.family ?? node?.inheritedTextStyle?.family ?? 'sans-serif',
184
+ family: style?.family ?? inherited?.family ?? 'sans-serif',
175
185
  size: size * s,
176
- weight: style?.weight ?? 'normal',
177
- // dropping this would measure a different face from the one drawn, and
178
- // the popup sized here would be the wrong width for its own label
179
- variations: style?.variations,
186
+ weight: style?.weight ?? inherited?.weight ?? 'normal',
187
+ style: style?.style ?? inherited?.style,
188
+ variations: style?.variations ?? inherited?.variations,
180
189
  });
181
190
  return { width: layout.width / s, height: layout.height / s };
182
191
  }