@jupyterlab/ui-components 4.7.0-beta.0 → 4.7.0-beta.1

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.
@@ -327,6 +327,10 @@ export class Toolbar<T extends Widget = Widget> extends Widget {
327
327
  */
328
328
  handleEvent(event: Event): void {
329
329
  switch (event.type) {
330
+ case 'pointerdown':
331
+ case 'keydown':
332
+ this._focusBeforeClick = document.activeElement;
333
+ break;
330
334
  case 'click':
331
335
  this.handleClick(event);
332
336
  break;
@@ -342,6 +346,9 @@ export class Toolbar<T extends Widget = Widget> extends Widget {
342
346
  // Stop propagating the click outside the toolbar
343
347
  event.stopPropagation();
344
348
 
349
+ const focusBeforeClick = this._focusBeforeClick;
350
+ this._focusBeforeClick = null;
351
+
345
352
  // Clicking a label focuses the corresponding control
346
353
  // that is linked with `for` attribute, so let it be.
347
354
  if (event.target instanceof HTMLLabelElement) {
@@ -356,6 +363,16 @@ export class Toolbar<T extends Widget = Widget> extends Widget {
356
363
  return;
357
364
  }
358
365
 
366
+ // If this click moved the focus out of the toolbar, for example to a menu,
367
+ // let it be. The focus is on the body when the click did not focus anything.
368
+ if (
369
+ focusBeforeClick !== null &&
370
+ document.activeElement !== focusBeforeClick &&
371
+ document.activeElement !== document.body
372
+ ) {
373
+ return;
374
+ }
375
+
359
376
  // Otherwise, activate the parent widget, which may take focus if desired.
360
377
  if (this.parent) {
361
378
  this.parent.activate();
@@ -367,6 +384,8 @@ export class Toolbar<T extends Widget = Widget> extends Widget {
367
384
  */
368
385
  protected onAfterAttach(msg: Message): void {
369
386
  this.node.addEventListener('click', this);
387
+ this.node.addEventListener('pointerdown', this);
388
+ this.node.addEventListener('keydown', this);
370
389
  }
371
390
 
372
391
  /**
@@ -374,9 +393,12 @@ export class Toolbar<T extends Widget = Widget> extends Widget {
374
393
  */
375
394
  protected onBeforeDetach(msg: Message): void {
376
395
  this.node.removeEventListener('click', this);
396
+ this.node.removeEventListener('pointerdown', this);
397
+ this.node.removeEventListener('keydown', this);
377
398
  }
378
399
 
379
400
  noFocusOnClick: boolean;
401
+ private _focusBeforeClick: Element | null = null;
380
402
  }
381
403
 
382
404
  /**
@@ -1302,6 +1302,24 @@ export class WindowedList<
1302
1302
  const { clientHeight, scrollHeight, scrollTop } =
1303
1303
  event.currentTarget as HTMLDivElement;
1304
1304
 
1305
+ // A scroll that the list did not request, such as one with the mouse
1306
+ // wheel, stops the list from scrolling back to the last requested
1307
+ // item. The type check excludes the synthetic onScroll call made
1308
+ // when windowing is toggled, which carries no event type.
1309
+ // When the list requests an offset past the end (such as the last
1310
+ // item plus a margin), the browser scrolls only to the end, so the
1311
+ // comparison limits the offset to the end.
1312
+ if (
1313
+ event.type === 'scroll' &&
1314
+ !this._scrollUpdateWasRequested &&
1315
+ Math.abs(
1316
+ Math.min(this.viewModel.scrollOffset, scrollHeight - clientHeight) -
1317
+ scrollTop
1318
+ ) > 1
1319
+ ) {
1320
+ this._scrollToItem = null;
1321
+ }
1322
+
1305
1323
  // TBC Firefox is emitting two events one with 1px diff then the _real_ scroll
1306
1324
  if (
1307
1325
  !this._scrollUpdateWasRequested &&
@@ -1,3 +1,3 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
2
- <path fill="#616161" d="M5 2h10l5 5v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6h1v2l4-3-4-3v2H3V4a2 2 0 0 1 2-2m7 16h4v-2h-4zm0-4h6v-2h-6zm0-4h6V8h-6zm-2 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2m-7-2v2H1v-2z" class="jp-icon3"/>
2
+ <path fill="#616161" d="M5 2h10l5 5v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6h1v2l4-3-4-3v2H3V4a2 2 0 0 1 2-2m7 16h4v-2h-4zm0-4h6v-2h-6zm0-4h6V8h-6zm-2 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2m-7-2v2H1v-2z" class="jp-icon3 jp-icon-selectable"/>
3
3
  </svg>
@@ -112,3 +112,46 @@
112
112
  text-overflow: ellipsis;
113
113
  white-space: nowrap;
114
114
  }
115
+
116
+ .jp-AccordionPanel-dragHandle {
117
+ display: none;
118
+ touch-action: none;
119
+ align-items: center;
120
+ flex-shrink: 0;
121
+ padding: 0 4px;
122
+ opacity: 0.5;
123
+ cursor: grab;
124
+ }
125
+
126
+ .jp-AccordionPanel-dragHandle::before {
127
+ content: '⠿';
128
+ font-size: var(--jp-ui-font-size1);
129
+ line-height: 1;
130
+ color: var(--jp-ui-font-color1);
131
+ }
132
+
133
+ .jp-mod-dragging .jp-AccordionPanel-dragHandle {
134
+ cursor: grabbing;
135
+ }
136
+
137
+ .jp-AccordionPanel-dropIndicator {
138
+ position: absolute;
139
+ left: 0;
140
+ right: 0;
141
+ height: 2px;
142
+ background-color: var(--jp-brand-color1);
143
+ pointer-events: none;
144
+ z-index: 10;
145
+ }
146
+
147
+ .jp-mod-reorderable > .lm-AccordionPanel-title > .jp-AccordionPanel-dragHandle {
148
+ display: inline-flex;
149
+ }
150
+
151
+ .lm-AccordionPanel[data-orientation='horizontal']
152
+ > .jp-AccordionPanel-dropIndicator {
153
+ top: 0;
154
+ bottom: 0;
155
+ width: 2px;
156
+ height: auto;
157
+ }