ember.js
ember.js copied to clipboard
[Bug] LinkTo do not generates href when @model is defined as undefined
🐞 Describe the Bug
When using LinkTo in a component and we want @model
to be optional, the href is not being generated if no model is provided.
🔬 Minimal Reproduction
https://gist.github.com/rogeraraujo90/bc68849c7bf81bba7e0127706c690111
😕 Actual Behavior
The href is generated as <current-route>#
🤔 Expected Behavior
The href should be generated correctly to the provided route.
PS: If I remove the @model
from the LinkTo component the href is generated correctly in my Ember version. Is not working well on Twiddle.
🌍 Environment
- Ember: 3.28.8
- Node.js/npm: 14.16.1
- OS: Windows
- Browser: Brave (chromium based)
➕ Additional Context
Even though I couldn't fix the problem in the twiddle, in my project I could by removing the @model
param in my component. But this is not ideal because since this is a component, I would like to have the possibility to pass a model or not.
Discord discussion: https://discord.com/channels/480462759797063690/483601670685720591/943929878108069978
I don't think this is a bug.
Can you write out in code what you mean by "if no model is provided"? Your description seems to disagree with itself, as you say that removing the @model
named argument does what you what.
Your reproduction doesn't include the router, so we also don't know what dynamic segments the route might be expecting. If you're optionally passing a model to a route that does not have dynamic segments then you will have problems down the line, as a refresh will not have the same behavior as a transition. In this case I would recommend a service to manage the data.