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

fix wrong tabs layout on validation error after page reload #5992

Merged
merged 1 commit into from
Nov 1, 2023
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
4 changes: 0 additions & 4 deletions assets/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export default class Autocomplete
return this.#createAutocompleteWithHtmlContents(element);
}

// needed because choice fields can be displayed as a expanded list of
// values without autocompletion. See https://github.com/EasyCorp/EasyAdminBundle/pull/5705
if (! element.hasAttribute('value')) return;

return this.#createAutocomplete(element);
}

Expand Down
1 change: 0 additions & 1 deletion src/Factory/FormLayoutFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ private function linearizeLayoutConfiguration(FieldCollection $fields): void
'ea_tab_id' => $tabId,
'ea_css_class' => $fieldDto->getCssClass(),
'ea_help' => $fieldDto->getHelp(),
'ea_tab_is_active' => $isTabActive,
]);

$tabs[$tabId] = $fieldDto;
Expand Down
6 changes: 6 additions & 0 deletions src/Form/Filter/Type/ChoiceFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$multiple = (bool) $builder->get('value')->getOption('multiple');

// if the filter shows the values as checkboxes or radio buttons, remove the
// attribute that turns the <select> into an autocomplete widget
if (true === ($options['value_type_options']['expanded'] ?? false)) {
unset($options['value_type_options']['attr']['data-ea-widget']);
}

$builder->addModelTransformer(new CallbackTransformer(
static fn ($data) => $data,
static function ($data) use ($multiple) {
Expand Down
2 changes: 0 additions & 2 deletions src/Form/Type/Layout/EaFormTabPaneOpenType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function configureOptions(OptionsResolver $resolver): void
->define('ea_tab_id')->allowedTypes('string')
->define('ea_css_class')->default(null)->allowedTypes('string', 'null')
->define('ea_help')->default(null)->allowedTypes(TranslatableInterface::class, 'string', 'null')
->define('ea_tab_is_active')->default(false)->allowedTypes('boolean')
;
}

Expand All @@ -32,7 +31,6 @@ public function buildView(FormView $view, FormInterface $form, array $options):
$view->vars['ea_tab_id'] = $options['ea_tab_id'];
$view->vars['ea_css_class'] = $options['ea_css_class'];
$view->vars['ea_help'] = $options['ea_help'];
$view->vars['ea_tab_is_active'] = $options['ea_tab_is_active'];
}

public function getBlockPrefix(): string
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Resources/public/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"/app.052a1081.rtl.css"
],
"js": [
"/app.e7951020.js"
"/app.1357e916.js"
]
},
"form": {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app.css": "app.052a1081.css",
"app.rtl.css": "app.052a1081.rtl.css",
"app.js": "app.e7951020.js",
"app.js": "app.1357e916.js",
"form.js": "form.fc39362b.js",
"page-layout.js": "page-layout.3347892e.js",
"page-color-scheme.js": "page-color-scheme.a1970567.js",
Expand Down
2 changes: 0 additions & 2 deletions src/Resources/views/crud/detail.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
{% endfor %}
{% endblock %}

{% block content_footer_wrapper '' %}

{% block main %}
{% block detail_fields %}
<div class="row">
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/views/crud/form_theme.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,10 @@
{% endblock ea_form_tabpane_group_close_row %}

{% block ea_form_tabpane_open_row %}
{% set tab_is_active_option_name = constant('EasyCorp\\Bundle\\EasyAdminBundle\\Field\\FormField::OPTION_TAB_IS_ACTIVE') %}
{% set field = form.vars.ea_vars.field %}
<div class="tab-content">
<div id="{{ ea_tab_id }}" class="tab-pane {% if ea_tab_is_active %}active{% endif %} {{ ea_css_class }}">
<div id="{{ ea_tab_id }}" class="tab-pane {% if field.getCustomOption(tab_is_active_option_name) %}active{% endif %} {{ ea_css_class }}">
{% if ea_help %}
<div class="content-header-help tab-help">
{{ ea_help|trans(domain = ea.i18n.translationDomain)|raw }}
Expand Down