118223: Stop space from scrolling down page

This commit is contained in:
Andreas Awouters
2024-10-04 09:40:20 +02:00
parent 181ea6d7c9
commit 2e1b1489b6
3 changed files with 12 additions and 3 deletions

View File

@@ -138,6 +138,7 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
// Otherwise we might clear the selection when a different action was intended, e.g. clicking a button or selecting
// a different bitstream.
if (event.target instanceof Element && event.target.tagName === 'BODY') {
event.preventDefault();
this.itemBitstreamsService.clearSelection();
}
}

View File

@@ -82,7 +82,7 @@
<th class="bitstream-name row-element {{ columnSizes.columns[0].buildClasses() }}"
scope="row" id="{{ entry.nameStripped }}" headers="{{ bundleName }} name">
<div class="drag-handle text-muted float-left p-1 mr-2" tabindex="0" cdkDragHandle
(keyup.enter)="select(entry)" (keyup.space)="select(entry)" (click)="select(entry)">
(keydown.enter)="select($event, entry)" (keydown.space)="select($event, entry)" (click)="select($event, entry)">
<i class="fas fa-grip-vertical fa-fw"
[title]="'item.edit.bitstreams.edit.buttons.drag' | translate"></i>
</div>

View File

@@ -423,9 +423,17 @@ export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy {
* Handles a select action for the provided bitstream entry.
* If the selected bitstream is currently selected, the selection is cleared.
* If no, or a different bitstream, is selected, the provided bitstream becomes the selected bitstream.
* @param bitstream
* @param event The event that triggered the select action
* @param bitstream The bitstream that is the target of the select action
*/
select(bitstream: BitstreamTableEntry) {
select(event: UIEvent, bitstream: BitstreamTableEntry) {
event.preventDefault();
if (event instanceof KeyboardEvent && event.repeat) {
// Don't handle hold events, otherwise it would change rapidly between being selected and unselected
return;
}
const selectedBitstream = this.itemBitstreamsService.getSelectedBitstream();
if (hasValue(selectedBitstream) && selectedBitstream.bitstream === bitstream) {