For the complete documentation index, see llms.txt
Saltar al contenido principal

Programmatic control

You can open the feedback modal from your own JavaScript instead of relying on the built-in <feedback-button> trigger. This is useful when you want a custom trigger, such as a link, an icon, or a keyboard shortcut.

The openModal() method

<feedback-modal> exposes a public openModal() method:

openModal(): Promise<void>

Calling it opens the feedback modal, playing the same entrance animation as when a user clicks a <feedback-button>.

openModal() is only available on <feedback-modal>. <feedback-button> doesn't expose this method: it calls openModal() on its own internal <feedback-modal> element when clicked.

Usage

To call openModal(), get a reference to the <feedback-modal> element and call the method on it:

  1. Add a <feedback-modal> element to your page with an id you can select later:

    <feedback-modal id="my-feedback-modal" project="YOUR_PROJECT_ID"></feedback-modal>
  2. Add your own trigger element, such as a link or icon:

    <a href="#" id="custom-feedback-trigger">Give feedback</a>
  3. Get a reference to the <feedback-modal> element and call openModal() when your trigger is activated:

    document.addEventListener('DOMContentLoaded', () => {
    const feedbackModal = document.getElementById('my-feedback-modal');
    const trigger = document.getElementById('custom-feedback-trigger');

    trigger.addEventListener('click', (event) => {
    event.preventDefault();
    feedbackModal.openModal();
    });
    });

See Embedded mode if you want the feedback form to display without any trigger at all.