Skip to content
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

[DOC] Correctly mark public link-to component named arguments #19348

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions packages/@ember/-internals/glimmer/lib/components/link-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,6 @@ import layout from '../templates/link-to';
When transitioning into the linked route, the `model` hook will
be triggered with parameters including this passed identifier.

### Allowing Default Action

By default the `<LinkTo>` component prevents the default browser action by calling
`preventDefault()` to avoid reloading the browser page.

If you need to trigger a full browser reload pass `@preventDefault={{false}}`:

```handlebars
<LinkTo @route='photoGallery' @model={{this.aPhotoId}} @preventDefault={{false}}>
{{this.aPhotoId.title}}
</LinkTo>
```

### Supplying a `tagName`

By default `<LinkTo>` renders an `<a>` element. This can be overridden for a single use of
Expand Down Expand Up @@ -380,7 +367,7 @@ const LinkComponent = EmberComponent.extend({
@property loadingClass
@type String
@default loading
@private
@public
**/
loadingClass: 'loading',

Expand All @@ -391,7 +378,7 @@ const LinkComponent = EmberComponent.extend({
@property disabledClass
@type String
@default disabled
@private
@public
**/
disabledClass: 'disabled',

Expand All @@ -406,6 +393,26 @@ const LinkComponent = EmberComponent.extend({
**/
replace: false,

/**
Determines whether the `LinkComponent` will prevent the default
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the description of the Allowing Default Action section in the LinkTo API docs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think about it, I wonder if this should just be deprecated and removed as part of RFC 707.

This seems only useful in the context of changing the tagName to something other than <a> (which is deprecated in RFC 707).

When the tagName is <a>, the default action of the browser is to navigate away, so there is no sense in not preventing it.

Thoughts?

Looping in @rwjblue as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I completely understand what you mean. I've never used @preventDefault myself, but I can imagine it being useful for some use cases to open a route in a new tab.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow sorry, scratch that. I was confused. Yeah I can't immediately imagine a scenario where a refresh is desired.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chancancode - ya seems correct to me

browser action by calling preventDefault() to avoid reloading
the browser page.

If you need to trigger a full browser reload pass `@preventDefault={{false}}`:

```handlebars
<LinkTo @route='photoGallery' @model={{this.aPhotoId}} @preventDefault={{false}}>
{{this.aPhotoId.title}}
</LinkTo>
```

@property preventDefault
@type Boolean
@default true
@private
**/
preventDefault: true,

/**
By default this component will forward `href`, `title`, `rel`, `tabindex`, and `target`
arguments to attributes on the component's element. When invoked with `{{link-to}}`, you can
Expand Down Expand Up @@ -555,7 +562,7 @@ const LinkComponent = EmberComponent.extend({

When `true`, interactions with the element will not trigger route changes.
@property disabled
@private
@public
*/
disabled: computed({
get(_key: string): boolean {
Expand Down
1 change: 1 addition & 0 deletions tests/docs/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ module.exports = {
'pauseTest',
'popObject',
'positionalParams',
'preventDefault',
'promise',
'property',
'pushObject',
Expand Down