Skip to content

Commit

Permalink
Merge pull request #235 from Oliver-ctrlo/uiux
Browse files Browse the repository at this point in the history
Keyboard functionality for the record-popup
  • Loading branch information
abeverley authored Sep 25, 2023
2 parents e923313 + 206060a commit 7d6a86a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/frontend/components/more-less/lib/disclosure-widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ const onDisclosureMouseout = function(e) {
}

const setupDisclosureWidgets = function(context) {
$('.trigger[aria-expanded]', context).on('click', onDisclosureClick)
$('.trigger[aria-expanded]', context).on('click keydown', function(ev) {
if (ev.type === 'click' || (ev.type === 'keydown' && (ev.which === 13 || ev.which === 32))) {
ev.preventDefault();
onDisclosureClick.call(this, ev);
}
});

// Also show/hide disclosures on hover for widgets with the data-expand-on-hover attribute set to true
$('.trigger[aria-expanded][data-expand-on-hover=true]', context).on('mouseover', onDisclosureMouseover)
Expand Down
8 changes: 6 additions & 2 deletions src/frontend/components/popover/lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ class PopoverComponent extends Component {

this.popover.removeClass(this.strShowClassName)
this.arrow.removeClass(this.strShowClassName)
button.click( (ev) => { this.handleClick(ev) })
button.on('click keydown', (ev) => {
if (ev.type === 'click' || (ev.type === 'keydown' && (ev.which === 13 || ev.which === 32))) {
ev.preventDefault()
this.handleClick(ev) }
})
}

handleClick(ev) {
const target = $(ev.target)

this.togglePopover()
ev.stopPropagation();

// TODO: add listener to document when clicking outside the popover to close it
// (disabled for now because it caused errors)
Expand Down
6 changes: 5 additions & 1 deletion src/frontend/components/record-popup/lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ class RecordPopupComponent extends Component {
}

initRecordPopup() {
$(this.element).on('click', (ev) => { this.handleClick(ev) })
$(this.element).on('click keydown', (ev) => {
if (ev.type === 'click' || (ev.type === 'keydown' && (ev.which === 13 || ev.which === 32))) {
this.handleClick(ev)
})
}
}

handleClick(ev) {
Expand Down

0 comments on commit 7d6a86a

Please sign in to comment.