ableplayer / ableplayer-wordpress

Able Player plugin for WordPress
Other
5 stars 4 forks source link

Able Player breaks Collapse elements from Bootstrap #11

Closed MarHerUMR closed 5 months ago

MarHerUMR commented 5 months ago

Describe the bug

Able Player breaks Collapse elements from Bootstrap when used on the same page.

To Reproduce Steps to reproduce the behavior:

  1. Install the Able Player WordPress Plugin
  2. Create a page or post with a able player video container
  3. Load Bootstrap (tested with version 3.4)
  4. Create a closed Collapse element on the page
  5. Click on the Collapse element in order to open it.
  6. Click on the Collapse element again in order to close it. It will not close again.

Expected behavior

When using Able Player and Bootstrap the Collapse elements should keep working.

Desktop (please complete the following information):

Additional context

Bootstrap uses $(document).on() to handle the interactions with collapsibles:

 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
    var $this   = $(this)

    if (!$this.attr('data-target')) e.preventDefault()

    var $target = getTargetFromTrigger($this)
    var data    = $target.data('bs.collapse')
    var option  = data ? 'toggle' : $this.data()

    Plugin.call($target, option)
  })

Source

Able Player uses the same method in order to "init speech before it's needed" and disables the event listener again.

                        greeting.onstart = function(e) {
                            // utterance has started 
                            $(document).off('click'); // unbind the click event listener
                        }

Source

By removing the event listener for Able Player the event listener for Boostrap is removed as well. Therefore the collapsibles no longer works.

joedolson commented 5 months ago

This sounds like an issue with AblePlayer itself, rather than with the WordPress plugin; can you confirm that this only occurs when using the plugin?

MarHerUMR commented 5 months ago

You are righ, it's a problem of Able Player itself. I'm taking it there. Sorry for the noise.

joedolson commented 5 months ago

No worries! Thanks for raising issues!