-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Suggestion: Adding Directive #5607
Comments
Honestly, I think one of the serious advantage of Blazor compared to other frameworks is its simplicity : there is a small amount of concept in the framework (page / component). In the angular world you learn a new one every day (https://angular.io/guide/glossary). When asking a feature maybe we could tell which case cannot be resolved with the current framework state instead of grabbing concept from others. Do you have any case in mind where the current framework cannot help you ? |
I wouldn't say grabbing features from others rather than taking advantages. However, the simplicity and reusing C# skills are one of the reasons that Blazor got my heart :-) Directives are really powerful when you want for example to extend new features and behaviours to an existing components. Let's say that you have a native component "input" and you'd like it behaves somehow when the user focus on it. It wouldn't be so nice to create a new abstract component to do this and then you have to manage all others attributes including accessibility and so on. Hope I made it clear. Happy blazoring! |
Agree, some concept of attribute directives (aka custom bindings in knockout) is critical. Components are good, but they don't go nearly far enough. |
Any chance to have this feature ASAP? 🙄 |
@asyncoder This one is a bit further down our backlog right now. We need to first land getting the basics of Razor Components into ASP.NET Core 3.0. But if anyone wants to submit some design proposals for what cross cutting directives in Blazor might look like that would be fine. |
So I'd like to simply give some input about what I like and don't like about the general use of directives and how I feel would be a good investment:
Feel free to comment or criticise. |
@RemiBou why directives are sometimes preferred: I want to extend the This can still be easily implemented using a component. But now I want to style it and add the This is the result of blazor components not existing in the DOM itself. Which keeps the DOM clean and readable, but now in this case also results in some responsibilities shifted to a child component since the parent has no way of editing it, or a lot of code needs to be added to the child component to support it. Both are not preferred in this case. |
@chanan found a workaround on the blazorstrap repo here https://github.com/chanan/BlazorStrap/blob/master/src/BlazorStrap/DynamicElement.cs It's used here https://github.com/chanan/BlazorStrap/blob/d771191f7572aae1aba540c8f87fe81695a621d5/src/BlazorStrap/Progress.cshtml |
What about following?
|
In Angular, we've used <input trim="blur"> Hoping to get something similar with Blazor Closest I got so far is.. <input @bind="Foo" onblur="this.value=this.value.trim()"> |
I switched from Angular to Aurelia a few years ago because of Aurelia's simplicity. Aurelia has "Custom Attributes" which allows you to add behavior to any element in the DOM. The Blazor team should look at how Aurelia implements this as it is simple and intuitive. http://aurelia.io/docs/templating/custom-attributes |
Is there any plan for this in near feature. ? |
I would also strongly favor the possibility to be able to add behavior to existing html elements : It is preferred when possible to use existing html elements over custom elements to keep html as close to the standard as possible. Input elements should remain input elements ... buttons should remain buttons. Main problem is, when you wrap eg. a button inside a custom button component, you have to expose almost every aspect of an html button element to be as flexible as possible (properties and events). Also , you'd be more future proof, when html adds new attributes/properties/events, you would be able to use them, which is not the case when the button is wrapped inside a component. (and when this custom component is not under your control you have to wait until the external library updates) |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
I don't know for sure, but suppose you have an input element wrapped inside a component, and this component is inside a fieldset. When the fieldset is set to disabled, the component should be disabled as well... Could be more difficult. I also wonder about aria attributes, custom styling, ... which maybe would require additional coding ... |
Nice feature to have. |
This will also helps MBB. |
Sounds like a reasonable proposition to me, I think directives can help you organize better and improve readability |
So, here is a typical case, that is to apply drag-movable feature to any HTML element like that in Angular —— by just attach a directive to the element. In fact, the so-called "simplicity" is truely |
Thanks for contacting us. |
@mkArtakMSFT we want attached properties for blazor like in XAML, thats all |
I thought this was already a Blazor feature. |
So this issue, although mentioning Angular 12 times and Aurelia six times, is now closed after .. four years - because it is not too specific. Great job. |
@mkArtakMSFT If you just looked at custom attributes in Aurelia like I suggest a long time ago, you would perhaps understand. Custom attributes are somewhat "general", which is what we are all looking for. |
I'd love to see the ability of supporting also directives, same principle as Angular.
Thanks!
The text was updated successfully, but these errors were encountered: