-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adding AutoCompleteBox extension for setting ItemTemplate #244
Adding AutoCompleteBox extension for setting ItemTemplate #244
Conversation
I've just added a few commits - unrelated to the ItemTemplate setting, but not to the |
static member inline itemTemplate(this: WidgetBuilder<'msg, #IFabAutoCompleteBox>, template: 'item -> WidgetBuilder<'msg, 'widget>) = | ||
this.AddScalar(AutoCompleteBox.ItemTemplate.WithValue(WidgetHelpers.compileTemplate template)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a good place to compile the builder (here named template
) into a template? Or do I lose the ability to identify different builders for the equality comparison by doing so? I'm doing it here because I was unable to declare the ItemTemplate
attribute value with the open generic signature of the builder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No here. This is already done on WidgetHelpers.buildItems
as part of the WidgetBuilder constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a second look. It is ok to have compileTemplate
as a separate function.
-
template: 'item -> WidgetBuilder<'msg, 'widget>
will be passing'item
and then will be unboxed whenWidgetDataTemplate
is building the template. -
One thing we can do is to use
#IFabControl
instead of'widget
static member inline itemTemplate(this: WidgetBuilder<'msg, #IFabAutoCompleteBox>, template: 'item -> WidgetBuilder<'msg, 'widget>) = | ||
this.AddScalar(AutoCompleteBox.ItemTemplate.WithValue(WidgetHelpers.compileTemplate template)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No here. This is already done on WidgetHelpers.buildItems
as part of the WidgetBuilder constructor
ebd9f20
to
9bfb5c6
Compare
4fa1e6e
to
37ac190
Compare
Includes some clean up, refactoring and renaming in separate commits.
Please take a good hard look at my implementation of the
AutoCompleteBox.ItemTemplate
attribute. It works - but I'm not at all certain whether I've used the correct of the many (sadly sparsely documented and hard to understand)Attributes.define*
variants.Neither have I checked whether the attempted reference equality comparison works as intended with compiled template builders - because I'm not certain what the exact intent of the equality comparison is. My guess is to prevent unnecessary re-rendering? Either way, please have a closer look at that as well and test it - because I don't really know what to look out for beyond the working samples.