PARIS
Account created on 26 April 2010, over 14 years ago
#

Merge Requests

More

Recent comments

🇫🇷France just_like_good_vibes PARIS

looks ok for merge. then i just rebased to prepare merge

🇫🇷France just_like_good_vibes PARIS

let's note, we clean the data for normalization but not everything.

🇫🇷France just_like_good_vibes PARIS

- we need a comment into the convert to indicates normalization will clean bad strings

- update noramlization to clean properly

🇫🇷France just_like_good_vibes PARIS

ok, seen during the weekly

we will deprecate the "HTML class source", still usable the same way.

but, the recommended source is Attributes, and the processing of the value is more elaborate.
we check if "=" sign is inside the value,
- if yes : in the attributes string format
- otherwide : a list of classes

so validation and getPropValue are changing for the better :)

let's update also the default source

🇫🇷France just_like_good_vibes PARIS

i don't know why it's for me, i send it back to christian :)

🇫🇷France just_like_good_vibes PARIS

i added a few minor changes.
and removed the unwanted tests. please review Christian :)

🇫🇷France just_like_good_vibes PARIS

we need to address this more carefully, the initial work posted by sourav_paul did not carefully check for existing attributes in the tags.

🇫🇷France just_like_good_vibes PARIS

just_like_good_vibes made their first commit to this issue’s fork.

🇫🇷France just_like_good_vibes PARIS

ok Christian, for review please :)
it should be ready for merge

🇫🇷France just_like_good_vibes PARIS

ready for review, who wants to take it?

🇫🇷France just_like_good_vibes PARIS

i think we already have everything except :

- using a view : using field formater inside a views row field. --> belongs to ui_patterns_field_formatters
- using a component block in the UI -> we have this in layout-builder but not in ui place blocks --> belongs to ui_patterns_blocks

🇫🇷France just_like_good_vibes PARIS

hmm no, it's not normal.
i need to investigate and i will post a correction

🇫🇷France just_like_good_vibes PARIS

Hello, i wonder if, like me, other people are needing this?
it would be great to continue the work.

🇫🇷France just_like_good_vibes PARIS

hello,
in fact this is a core bug about treating correctly unicode in pcre patterns.

the bad code is in FormElementBase, function validatePattern.

Our regex supports unicode, but drupal form and "#pattern" processing is not enough advanced to allow it.

i will submit a patch

🇫🇷France just_like_good_vibes PARIS

did some massive work over there, please review :)

i think we should improve two prop types : ListPropType and NumberPropType.
A the moment, their normalization is not strong enough imho.

let's tackle this in separate tickets.

🇫🇷France just_like_good_vibes PARIS

just_like_good_vibes changed the visibility of the branch 3469665-test-proptypeinterfacenormalize to hidden.

🇫🇷France just_like_good_vibes PARIS

hello, it looks like now it works, i can see the checkboxes.
could you please check @smustgrave ? thank. you :)

🇫🇷France just_like_good_vibes PARIS

i just gave a test with a fresh 11.1.0 drupal and the last experience_builder from dev branch.

i did not receive the mentioned errors.
i managed to check the UI and almost nothing worked. My components were appearing but they are still in such an early stage, it seems difficult to check anything yet.

🇫🇷France just_like_good_vibes PARIS

hmm yes, i see sorry. i forgot that one.
so yes, we have this little mechanism but it covers only some sources, the ones deriving from SourcePluginPropValue.
Those sources are a bit specific : They have only a 'value' setting key, and they may use it in their form.
in those particular cases, we process the default value indicated in the prop json schema.
We can keep this behavior for those sources, but what about other sources ?

list of sources deriving from SourcePluginPropValue :

  • Drupal\ui_patterns\Plugin\UiPatterns\Source\CheckboxesWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\CheckboxWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\ClassAttributeWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\NumberWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\SelectWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\SelectsWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\TextfieldWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\UrlWidget


other noticeable sources (i also used the current ones from ui_icons and i filtered out the ones with slot in the prop_types)

  • Drupal\ui_icons_patterns\Plugin\UiPatterns\Source\IconSource
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\AttributesWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\BreadcrumbSource
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\EntityFieldSource
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\EntityLinksSource
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\EntityReferencedSource
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\FieldPropertySource
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\ListTextareaWidget
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\MenuSource
  • Drupal\ui_patterns\Plugin\UiPatterns\Source\PathSource
  • Drupal\ui_patterns_field_formatters\Plugin\UiPatterns\Source\FieldLabelSource
  • Drupal\ui_patterns_views\Plugin\UiPatterns\Source\ViewTitleSource
🇫🇷France just_like_good_vibes PARIS

hey hey, what about Option 4) we keep the strip tags behavior in string prop types and we do not introduce a new prop type to inject HTML into props. BUT, we implement this : if the JSON schema definition has contentMediaType: "text/html" , then we allow HTML to be placed into the string prop, and the normalization and preprocess on our side behaves in a different manner.

now i vote for option 4

🇫🇷France just_like_good_vibes PARIS

To add to this "brainstorm", imagine a slot with a default value which would be an insane render array or any random markup.
it is not realistic to have any slot source to be able to support that value as being "casted" into a source form.

Honestly, i would rather let sources be free to implement or not the default value handling, and we need maybe to add some little things to the current code :

> do we show/indicate the default value in prop/slot description ?
> do we add a "DefaultValue" source which job is to empty the source settings and let the default value be injected for sure ?

🇫🇷France just_like_good_vibes PARIS

I am not sure about the mechanism of default value we need/want, and the exact one we have today.
To my knowledge, we were not relying at all in sources, on the default value in the prop being edited.
but i may be wrong.
Right now, each source is independent and it would be each source responsibility to read from the prop definition, and fill the defaultSettings of the source, in order to make that value appear in the form.

so right now, default value in the definition seems not used in sources.

but what do we want to support ?

Question 1) : should the default value in prop definition appear on the source form that is editing that prop ?

Question 2) : If it appears, should we have "revert to default?" mechanism, maybe a "default value" checkbox, a defaultValue source or whatever?

Question 3) : When should we really apply default value? in other words, when is a source value really "null" and be replaced to the default. What if we want to really put null as a value?

🇫🇷France just_like_good_vibes PARIS

i find the remark interesting, but still we need to decide what to do :

- Before 🐛 LinkPropType normalization...suite Active , string prop type was unfiltered. String prop types are supposed to have only string and not tags, but it seems some people were abusing the original intent of prop types and (mistakenly) used them to convey html markup. We were like authorizing this (through twig usage or through weird sources like token ? )

- After 🐛 LinkPropType normalization...suite Active , which is now : we are stripping tags. Is-it a mistake? should we re-allow tags inside strings? (by the way, tags from forms won't work, like input for example, twig will filter them i guess) ?

Option 1) : we keep the strip tags. I would say then "work as expected". People are not supposed to free-ride string props to put markup in it. They should re-think their SDC component model and use slots for that. The benefit of that strip tags filtering is the ability to have a predictable behavior of string prop types. from a twig usage perspective, people can inject "stuff" (e.g. html) that may be the result of a rendering, and that stuff is cleaned by our normalization process to become nice string.

Option 2) : We remove the strip tags. We open the gate to strange things. but some people would be happy to not rewrite their SDC component, and ui patterns will support their strange usage. still this is not a real html support yet, would we allow also form elements ? (in that case a specific treatment in preprocess should be added).

Option 3) : We keep Option1), but we introduce the new prop type Pierre was talking about. Then, weird usage of string props with tags, would work if and only if SDC component definition would be patched with contentMediaType: "text/html" . That would be a compliance requirement of ui patterns 2. more elegant solution with a nasty new prop type.

Honestly, i like option 3) but it is still an open door to strange things with props. But strange things are going into a specific prop type at least instead of free-riding the nice String prop type.

we need to "vote", for the best option.

🇫🇷France just_like_good_vibes PARIS

i take it back to check and finish for merge

🇫🇷France just_like_good_vibes PARIS

one comment about the "with_context=false".
I knew the linter wanted to put "with_context: false", but it is written everywhere that the right code portion is "with_context=false".
so i was like confused.
what do you guys think?

🇫🇷France just_like_good_vibes PARIS

you mean adding an automatic test for stories? or which test(s)?

🇫🇷France just_like_good_vibes PARIS

Hello Christian,
you set in review but the MR is not green ?
do i still need to review it?

🇫🇷France just_like_good_vibes PARIS

And finally, i have corrected and give more strength to our normalization processes.

My advice, is that we could be more systematic to this approach, and factorize code a lot to do that process of "cleaning" what is injected into the components.
but, well, let's continue for now with that version, which seems to cope well with all our the submitted problematic usecases (i hope i did not forget any).

🇫🇷France just_like_good_vibes PARIS

new additions with feedback from multiple persons :) thank you all

🇫🇷France just_like_good_vibes PARIS

according to comments from 🐛 [2.0.0-rc1] normalization of slots triggers some unwanted filtering Active ,
there are new work to do on normalization.
i have opened a new separate issue https://www.drupal.org/project/ui_patterns/issues/3492211 🐛 LinkPropType normalization...suite Active

🇫🇷France just_like_good_vibes PARIS

hello,
this belongs to another ticket, because it is linkproptype normalization and not slot

🇫🇷France just_like_good_vibes PARIS

an error occured here, a pattern appeared instead of component. we reopen to merge the error.

🇫🇷France just_like_good_vibes PARIS

I just submitted the new proposition.
When no default value is defined for an enum :
- if enum has type compatible with string, and if not required, the default value is now empty string
- otherwise default value is first enum value

🇫🇷France just_like_good_vibes PARIS

yes we need to figure out the options.

First, how things are declared using SDC, in json schema

- type
- required
- default

The current code in normalize is trying to get the "default", like this :

return static::normalizeEnumValue($value, $enum) ?? static::enumDefaultValue($definition);

We are discussing the possibilities of changing the enumDefaultValue returned.

when there is not "default" declared in json schema, and when the type is explicitely defined (and would be further checked by SDC)
we indeed return the first enum value.
Perhaps we could refine this :
- if required is defined and true in the definition, we returned the first enum value (and not empty string)
- otherwise : depending on the type, we try to return a default 'empty' value .
-- type can be an array or a scalar if i am not wrong. when string is a compatible type, we return empty string,
-- otherwise, what do we return ? first enum value?

one again, we are in an edge case, where :
- the definition has not indicated a default value,
- the value passed is not part of the enum declared
- the enum is explicitely typed and the value will be validated.
- we try to guess a default valid value to avoid a failed validation, and the first enum is not good.

in the case of enum of type string, when declared without required, one would expect that it means optional with default value being empty string.

🇫🇷France just_like_good_vibes PARIS

"I want the prop to remain optional, so without value."
for this, it is a bit more tricky to do.
if you prop is of type "string", and you don't declare any "default",
and you still want an empty string as default :) ?

is empty string a possible enum value ?
and also i would rather put empty string as default...
because sometimes enum could have different types, mixed types..etc

i am curious about what Pierre thinks about that. maybe i am completly wrong in my approach.

Production build 0.71.5 2024