Skip to content

Commit

Permalink
Stopped bubbling
Browse files Browse the repository at this point in the history
Added a Stopprop to popover so it no longer bubbles up to the record pop-over.

Then added keyboard functionality and disabled default behaviour. As I was finding that the default button click (via keyboard) was being over-ridden by other events with specified key-down functionality.
  • Loading branch information
Oliver-ctrlo authored Sep 25, 2023
1 parent 6f334d4 commit 923a034
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 923a034

Please sign in to comment.