mirror of
https://gh.wpcy.net/https://github.com/elementor/elementor.git
synced 2026-06-18 04:33:19 +08:00
## PR Checklist <!-- Please check if your PR fulfills the following requirements: **Filling out the template is required.** Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. --> - [ ] The commit message follows our guidelines: https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md ## PR Type What kind of change does this PR introduce? <!-- Please check the one that applies to this PR using "x" with no spaces eg: [x]. --> - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, local variables) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] CI related changes - [ ] Documentation content changes - [ ] Other... Please describe: ## Summary This PR can be summarized in the following changelog entry: * ## Description An explanation of what is done in this PR * ## Test instructions This PR can be tested by following these steps: * ## Quality assurance - [ ] I have tested this code to the best of my abilities - [ ] I have added unittests to verify the code works as intended - [ ] Docs have been added / updated (for bug fixes / features) Fixes # <!--start_gitstream_placeholder--> ### ✨ PR Description ## 1. Problem & Context Centralizing widget promotion display logic into a unified event-driven system instead of scattered dialog calls. Enables consistent UX across atomic forms, locked widgets, and feature promotions while decoupling trigger points from UI rendering. ## 2. What Changed (Where) - **element.js**: Switched from `elementor.promotion.showDialog()` to `widget-promotion:open` custom event; added event propagation stop and variable extraction - **behavior.js**: Refactored four control handlers to use shared `dispatchPromotionEvent()` method instead of inline dialog configs - **app-manager.js** (both modules): Extracted iframe event binding into reusable `bindPreviewIframeEvents()` utility; unified mount logic via generic `mountCard()` method - **app.js**: Extracted placement/content resolution into pure functions; added `WidgetPromotionCard` support with RTL-aware positioning - **widget-promotion-card.js**: New component for widget promotions with optional "Free" chip for integrations ## 3. How It Works Event flow: click handler → `dispatchPromotionEvent()` / `widget-promotion:open` → `AppManager.attachWidgetPromotionListeners()` → `resolveWidgetPromotionData()` (normalizes widget types, falls back to config) → `mountCard()` → `App` determines placement based on RTL/anchor target → renders appropriate card component. Iframe listener cleanup on unmount prevents memory leaks. ## 4. Risks Minor: hardcoded offset `[-24, 8]` may misalign in edge layouts; fallback CTA text generation relies on config shape matching (mitigated by nullish coalescing). Widget type normalization via lowercase/strip-delimiters could collide for similar names. _Generated by LinearB AI and added by gitStream._ <sub>AI-generated content may contain inaccuracies. Please verify before using. 💡 **Tip:** You can customize your AI Description using **Guidelines** [Learn how](https://docs.gitstream.cm/automation-actions/#describe-changes)</sub> <!--end_gitstream_placeholder--> --------- Co-authored-by: Nikita Murzin <mykytamu@elementor.com> |
||
|---|---|---|
| .. | ||
| data | ||
| dev | ||
| images | ||
| lib | ||
| mask-shapes | ||
| shapes | ||
| svg-paths | ||