Skip to content

Commit

Permalink
Fix bug w/ missing New child button. Bump to 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed May 9, 2024
1 parent 72e2707 commit 949bc29
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.1.0 - 2024-05-09
### Fixed
- Fixed a bug that prevented the "New child" button from appearing in certain situations
### Changed
- Replaced the "New child" tooltip for the "New child" buttons with a "New child" `title` attribute.

## 2.0.0 - 2024-03-27
### Added
- Added Craft 5 compatibility
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mmikkel/child-me",
"description": "Easily create child elements",
"type": "craft-plugin",
"version": "2.0.0",
"version": "2.1.0",
"keywords": [
"craft",
"cms",
Expand Down
2 changes: 1 addition & 1 deletion src/ChildMe.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static function (RegisterElementTableAttributesEvent $event) {
Event::on(
$elementClass,
Element::EVENT_DEFINE_ATTRIBUTE_HTML,
function (DefineAttributeHtmlEvent $event) use ($elementClass) {
function (DefineAttributeHtmlEvent $event) {
if ($event->attribute !== '_childme_addChild') {
return;
}
Expand Down
20 changes: 12 additions & 8 deletions src/templates/childme-button.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
class="childme-button{{ hidden ? ' hidden' }}"
data-icon="plus"
aria-label="{{ 'New child'|t('app') }}"
>
<craft-tooltip>{{ 'New child'|t('app') }}</craft-tooltip>
</a>
title="{{ 'New child'|t('app') }}"
></a>
{% else %}
{# Create a disclosure menu, but neglect to add the [data-disclosure-trigger] attribute to, essentially, lazy-load the menu; otherwise Craft would create a 100 of these on pageload #}
<button type="button"
Expand All @@ -19,9 +18,8 @@
aria-controls="childme-menu-{{ element.id }}"
aria-expanded="false"
aria-label="{{ 'New child'|t('app') }}"
>
<craft-tooltip>{{ 'New child'|t('app') }}</craft-tooltip>
</button>
title="{{ 'New child'|t('app') }}"
></button>
<div id="childme-menu-{{ element.id }}" class="childme-menu menu menu--disclosure">
<ul>
{% for link in links %}
Expand All @@ -35,8 +33,14 @@
'--custom-sel-bg-color': link.color.cssVar(100)|default(false)
} : false
} %}
{% if link.icon %}
<span class="cp-icon small{{ link.color is defined ? " #{link.color.value}" }}">{{ link.icon|raw }}</span>
{% if link.icon|default %}
{{ tag('span', {
html: link.icon,
class: [
'cp-icon small',
link.color.value|default
]
}) }}
{% endif %}
{{ link.label }}
{% endtag %}
Expand Down

0 comments on commit 949bc29

Please sign in to comment.