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

Condition builder updates #11588

Merged
merged 11 commits into from
Jul 13, 2022
3 changes: 3 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
### Added
- Added `craft\events\IndexKeywordsEvent`.
- Added `craft\services\Search::EVENT_BEFORE_INDEX_KEYWORDS`. ([#11575](https://github.com/craftcms/cms/discussions/11575))

### Changed
- Improved condition builder accessibility. ([#11588](https://github.com/craftcms/cms/pull/11588))
2 changes: 1 addition & 1 deletion src/base/conditions/BaseConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function getHtml(): string

return
Html::beginTag('div', [
'class' => ['flex', 'flex-nowrap', 'flex-start'],
'class' => ['flex', 'flex-start'],
]) .
(count($operators) > 1
? (
Expand Down
4 changes: 4 additions & 0 deletions src/base/conditions/BaseDateRangeConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function getConfig(): array
protected function inputHtml(): string
{
return
Html::beginTag('div', ['class' => 'flex']) .
Html::beginTag('div', ['class' => ['flex', 'flex-nowrap']]) .
Html::label(Craft::t('app', 'From'), 'start-date-date') .
Html::tag('div',
Expand All @@ -96,6 +97,8 @@ protected function inputHtml(): string
'value' => $this->getStartDate(),
])
) .
Html::endTag('div') .
Html::beginTag('div', ['class' => ['flex', 'flex-nowrap']]) .
Html::label(Craft::t('app', 'To'), 'end-date-date') .
Html::tag('div',
Cp::dateHtml([
Expand All @@ -104,6 +107,7 @@ protected function inputHtml(): string
'value' => $this->getEndDate(),
])
) .
Html::endTag('div') .
Html::endTag('div');
}

Expand Down
2 changes: 1 addition & 1 deletion src/base/conditions/BaseMultiSelectConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function inputHtml(): string
Html::hiddenLabel($this->getLabel(), $multiSelectId) .
Cp::multiSelectHtml([
'id' => $multiSelectId,
'class' => 'selectize fullwidth',
'class' => 'selectize flex-grow',
'name' => 'values',
'values' => $this->_values,
'options' => $this->options(),
Expand Down
2 changes: 1 addition & 1 deletion src/base/conditions/BaseTextConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function inputHtml(): string
'name' => 'value',
'value' => $this->value,
'autocomplete' => false,
'class' => 'fullwidth',
'class' => 'flex-grow flex-shrink',
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/elements/conditions/RelatedToConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function inputHtml(): string
]) .
parent::inputHtml(),
[
'class' => ['flex', 'flex-nowrap'],
'class' => ['flex'],
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/web/assets/cp/src/css/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3432,6 +3432,15 @@ ul.tree,
margin-top: 6px;
display: block;
}

.selectize {
min-width: 100px;
}

.text.fullwidth {
min-width: 100px;
max-width: 100%;
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -2546,7 +2546,6 @@ const FilterHud = Garnish.HUD.extend({
this.$hud.find('.condition-container').on('htmx:load', () => {
this.setReady();
});

this.setFocus();
})
.catch(() => {
Expand Down Expand Up @@ -2575,7 +2574,7 @@ const FilterHud = Garnish.HUD.extend({
},

setFocus: function () {
this.$main.find('.condition-footer .add').focus();
Garnish.setFocusWithin(this.$main);
},

clear: function () {
Expand Down