Problem/Motivation

like we do for view in issue [2.0.0-beta1] Do we take care of the big object in views config?, we need to correct the field formatter plugins to correctly inject data through context instead of storing big data in component settings passed to rendering.

There is an issue about field formatter "ComponentFormatter" when used in a nested slot, using data from a field.
When the field has multiple values, it does render multiple component instead of one

There are multiple issues in the current codebase about contexts.
- field formatters in views do not always behave as expected.
- when componentFormatter and Component Formatter per item are nested inside each other, the behavior about the field items rendered is not as expected, and moreover when using "data from a field"
- other weird behaviors and cases, mostly based on contexts and multiple VS single value fields.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

just_like_good_vibes created an issue. See original summary.

just_like_good_vibes’s picture

Status: Active » Needs review

Ok, done.
I have added also some bonus :
- i fixed a bug in the context injected by field formatter, especially when used in views, where the bundle is unknown and set to empty string in our case.
- i refactored UI patterns views, to remove the existing service and use a trait for both row and style plugins. i fixed a few existing bugs in the codebase, especially related to view displays and default/overridden options.
- i added a new option to ViewRows source, that allows to use view rows as source, with a specific field only.

pdureau’s picture

pdureau’s picture

Assigned: pdureau » just_like_good_vibes
Status: Needs review » Needs work

Demo with DSFR's tabs:

  • The field formatter source doesn't show plugin form
  • Duplicated & nested display
  • Problem with context

Demo with Bootstrap's table:

  • Undefined array key "#ajax_url" in Drupal\ui_patterns\Element\ComponentForm::buildPropsForm()
  • Maybe this use case is not doable anyway because nested components in a single slot instead of single level component in 2 different slots

Also, careful with field label, if it is the displayed label from view field, it may not be useful to show it.

just_like_good_vibes’s picture

Status: Needs work » Needs review

please test again, should be better ;)

pdureau’s picture

pdureau’s picture

Assigned: pdureau » just_like_good_vibes
Status: Needs review » Needs work

pulled. And rebased from 2.0.x

During configuration

Seems OK but ComponentFormatter is available in the sources selector also for single value fields (like "title"). If selected, nothing happens. The plgin from is not displayed

After configuration, looking at the result

White screen of death:

TypeError: Drupal\ui_patterns_field_formatters\Plugin\Field\FieldFormatter\ComponentFormatterBase::checkContextSanity(): Argument #3 ($bundle) must be of type string, null given, called in modules/ui_patterns_field_formatters/src/Plugin/Field/FieldFormatter/ComponentFormatterBase.php on line 244 in Drupal\ui_patterns_field_formatters\Plugin\Field\FieldFormatter\ComponentFormatterBase->checkContextSanity() (line 282 of modules/ui_patterns_field_formatters/src/Plugin/Field/FieldFormatter/ComponentFormatterBase.php).

just_like_good_vibes’s picture

Status: Needs work » Needs review

after testing more, adding a few new tests,
i did some improvements on other edge cases.
it is supposed to be fine now :)
please review Pierre.

adding tests is really cool, i think we need really a lot of them.

pdureau’s picture

just_like_good_vibes’s picture

Component: UI Patterns Field Formatters [2.x only] » Code
just_like_good_vibes’s picture

Title: [2.0.0-beta1] Remove usage of setComponentSettingsExtra in field formatters in favor of injected contexts » [2.0.0-beta1] Remove usage of setComponentSettingsExtra in field formatters in favor of injected contexts + Fix contexts issues + Fix ComponentFormatter issues
Issue summary: View changes
just_like_good_vibes’s picture

Hello,
i have updated a little bit the title and description of the issue, which is now solving more problems than initially expected...
MR is rebased and fully green now :)

pdureau’s picture

Unfortunately, I will not be able to review today. you can merge yourself.

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » Unassigned
Status: Needs review » Fixed
pdureau’s picture

Status: Fixed » Closed (fixed)