Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: note event bubbling #3522

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api/accordion.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ import Toggle from '@site/static/usage/v8/accordion/toggle/index.md';

## Listen for Accordion State Changes

:::caution
Most `ionChange` events emitted by other components such as [Input](./input) and [Textarea](./textarea) bubble. As a result, these events will bubble up and cause your `ionChange` listener on the Accordion Group to fire if the associated components are used inside of an Accordion.

When using other components that emit `ionChange` inside of Accordion it is recommended to have the `ionChange` callback on Accordion Group check the `target` key on the event passed to the callback to verify that `ionChange` is coming from the Accordion Group and not any descendants.
:::

Developers can listen for the `ionChange` event to be notified when accordions expand or collapse.

import ListenChanges from '@site/static/usage/v8/accordion/listen-changes/index.md';
Expand Down
8 changes: 3 additions & 5 deletions plugins/docusaurus-plugin-ionic-component-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,9 @@ function renderEvents({ events }) {
}

return `
| Name | Description |
| --- | --- |
${events.map((event) => `| \`${event.event}\` | ${formatMultiline(event.docs)} |`).join('\n')}

`;
| Name | Description | Bubbles |
| --- | --- | --- |
${events.map((event) => `| \`${event.event}\` | ${formatMultiline(event.docs)} | \`${event.bubbles}\` |`).join('\n')}`;
Comment on lines +171 to +173
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

}

function renderMethods({ methods }) {
Expand Down
6 changes: 6 additions & 0 deletions versioned_docs/version-v7/api/accordion.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ import Toggle from '@site/static/usage/v7/accordion/toggle/index.md';

## Listen for Accordion State Changes

:::caution
Most `ionChange` events emitted by other components such as [Input](./input) and [Textarea](./textarea) bubble. As a result, these events will bubble up and cause your `ionChange` listener on the Accordion Group to fire if the associated components are used inside of an Accordion.

When using other components that emit `ionChange` inside of Accordion it is recommended to have the `ionChange` callback on Accordion Group check the `target` key on the event passed to the callback to verify that `ionChange` is coming from the Accordion Group and not any descendants.
:::

Developers can listen for the `ionChange` event to be notified when accordions expand or collapse.

import ListenChanges from '@site/static/usage/v7/accordion/listen-changes/index.md';
Expand Down