import $ from 'jquery'

export default (modal) => {
    $(document).on('click', '.finish.button', function () {
        chrome.runtime.sendMessage({ eventType: 'pop' });
        modal.modal('show');
    });
};

import $ from 'jquery'

export default (modal) => {
    $(document).on('click', '.finish.button', function () {
        setTimeout(function() {
            chrome.runtime.sendMessage({ eventType: 'pop' });
            modal.modal('show');
        }, 0)
    });
};

Set timeout on modal popper event listener
Set timeout on modal popper event listener

- In certain edge cases, the modal pop was racing another function on the page which changed the button state. In some cases the order of events was click on a 'Start' button, some js changes the 'Start' button to a 'Finish' button, then the click handler happens and since the event is delegated, it is only at this time that the button state is checked, the js sees that the triggering button is now a 'Finish' button and the modal is popped. The user sees that the modal is popped on a 'Start' button click. This timeout enforces the order of events to prevent this bug
