Skip to content

Commit 2e1b148

Browse files
committed
118223: Stop space from scrolling down page
1 parent 181ea6d commit 2e1b148

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
138138
// Otherwise we might clear the selection when a different action was intended, e.g. clicking a button or selecting
139139
// a different bitstream.
140140
if (event.target instanceof Element && event.target.tagName === 'BODY') {
141+
event.preventDefault();
141142
this.itemBitstreamsService.clearSelection();
142143
}
143144
}

src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<th class="bitstream-name row-element {{ columnSizes.columns[0].buildClasses() }}"
8383
scope="row" id="{{ entry.nameStripped }}" headers="{{ bundleName }} name">
8484
<div class="drag-handle text-muted float-left p-1 mr-2" tabindex="0" cdkDragHandle
85-
(keyup.enter)="select(entry)" (keyup.space)="select(entry)" (click)="select(entry)">
85+
(keydown.enter)="select($event, entry)" (keydown.space)="select($event, entry)" (click)="select($event, entry)">
8686
<i class="fas fa-grip-vertical fa-fw"
8787
[title]="'item.edit.bitstreams.edit.buttons.drag' | translate"></i>
8888
</div>

src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,17 @@ export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy {
423423
* Handles a select action for the provided bitstream entry.
424424
* If the selected bitstream is currently selected, the selection is cleared.
425425
* If no, or a different bitstream, is selected, the provided bitstream becomes the selected bitstream.
426-
* @param bitstream
426+
* @param event The event that triggered the select action
427+
* @param bitstream The bitstream that is the target of the select action
427428
*/
428-
select(bitstream: BitstreamTableEntry) {
429+
select(event: UIEvent, bitstream: BitstreamTableEntry) {
430+
event.preventDefault();
431+
432+
if (event instanceof KeyboardEvent && event.repeat) {
433+
// Don't handle hold events, otherwise it would change rapidly between being selected and unselected
434+
return;
435+
}
436+
429437
const selectedBitstream = this.itemBitstreamsService.getSelectedBitstream();
430438

431439
if (hasValue(selectedBitstream) && selectedBitstream.bitstream === bitstream) {

0 commit comments

Comments
 (0)