-
Notifications
You must be signed in to change notification settings - Fork 333
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
feat: add redirect url plugin #1082
Conversation
…guln/autocomplete into feat/ootb-redirect-plugin
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d5f8fc3:
|
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.
For me this looks good, but it requires reviews from other team members, as I've contributed too much of it.
/** | ||
* Functions to navigate to a URL. | ||
*/ | ||
navigator: AutocompleteNavigator<TItem>; |
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.
Wondering if it's worth providing the whole props here? It feels like just passing navigator
solves one scenario, but not others when people will introduce different plugins?
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.
I did debate when moving to pass only navigator that it could be interesting to pass the whole props, although as they probably would be spread, I guess it can wait until we have more need?
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.
We pass the state
object without spreading so I would rather see the whole props
object without spreading, no?
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.
yes, I see the argument for all of props to be passed in a single object too. I guess I was more thinking on how that's currently not an API we expose, and from now on props
would be available too.
packages/autocomplete-plugin-redirect-url/src/createRedirectUrlPlugin.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: François Chalifour <[email protected]>
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.
Great work! I have a few nitpicks that might help improve user experience.
packages/autocomplete-plugin-redirect-url/src/createRedirectUrlPlugin.ts
Outdated
Show resolved
Hide resolved
packages/autocomplete-plugin-redirect-url/src/createRedirectUrlPlugin.ts
Outdated
Show resolved
Hide resolved
packages/autocomplete-plugin-redirect-url/src/createRedirectUrlPlugin.ts
Outdated
Show resolved
Hide resolved
packages/autocomplete-plugin-redirect-url/src/createRedirectUrlPlugin.ts
Outdated
Show resolved
Hide resolved
packages/autocomplete-plugin-redirect-url/src/createRedirectUrlPlugin.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Dhaya <[email protected]>
packages/autocomplete-plugin-redirect-url/src/createRedirectUrlPlugin.ts
Outdated
Show resolved
Hide resolved
state: AutocompleteState<TItem>; | ||
}; | ||
|
||
type DefaultIndicator = { __default?: boolean }; |
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.
That's unconventional and not easy to understand why this is needed. Perhaps some JSDoc would help?
type DefaultIndicator = {
/**
* ...
*/
__default?: boolean;
};
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 d5f8fc3:
Optional key on a function to indicate it's the default value of this function.
This doesn't explain what it's used for so it doesn't provide much value...
The new Redirect URL plugin is used in conjunction with the dashboard / merchandising studio rule consequence "redirect to a url". It adds an item visually when a redirect matches, and a handler for onSubmit + onSelect to navigate to that URL.
See the RFC here.