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

Add initialSearchTerm prop #32

Merged
merged 6 commits into from
Sep 21, 2024

Conversation

manoelneto
Copy link
Contributor

This allows to control the search term by overriding the pickerContextValue.

@manoelneto
Copy link
Contributor Author

@MrBartusek can you check that?

@MrBartusek
Copy link
Owner

@manoelneto Hey, thanks for the PR. What is the motivation for this change, and how would it help our users? What are the use cases for this property?

@manoelneto
Copy link
Contributor Author

the idea is to make the search term controlled, so we can pass initial term for example.

@MrBartusek
Copy link
Owner

the idea is to make the search term controlled, so we can pass initial term for example.

What are the use cases of this? Can you give examples of how would it benefit the developer using this picker?

@manoelneto
Copy link
Contributor Author

Hey @MrBartusek, I'm not entirely sure if my solution is perfect, but I think it makes sense for the parent component to control the query term if needed. So, I came up with this approach that doesn't require too much code change.

By the way, I noticed that in the Storybook, the way you're passing the initial query is a bit off—it seems like you're simulating DOM events to change the term, which feels a bit against React patterns.

@MrBartusek
Copy link
Owner

I'm not entirely sure if my solution is perfect, but I think it makes sense for the parent component to control the query term if needed. So, I came up with this approach that doesn't require too much code change.

I want to know how would it be usefull to a developer. In which situation would anyone want to control the internal search term here

By the way, I noticed that in the Storybook, the way you're passing the initial query is a bit off—it seems like you're simulating DOM events to change the term, which feels a bit against React patterns.

These are internal test files, they are ment to simulate user actions.

@manoelneto
Copy link
Contributor Author

It's very usefull. When we render the gif component, we pass the initial query term. As in this example, sending a shoutout in our platform.

Screenshot 2024-08-22 at 08 01 11

We also have other use cases (celebrating birthdays) that is also usefull.

@manoelneto
Copy link
Contributor Author

Unrelated, not sure if you noticed, but I also added the powered by tenor image below the searchbar to our internal fork, which is also necessary to complain with tenor terms.

@MrBartusek
Copy link
Owner

Unrelated, not sure if you noticed, but I also added the powered by tenor image below the searchbar to our internal fork, which is also necessary to complain with tenor terms.

For that reffer to: https://github.com/MrBartusek/gif-picker-react#what-to-know-before-using

@TheNoobiCat

This comment was marked as off-topic.

@jaxomlotus
Copy link

jaxomlotus commented Sep 9, 2024

@MrBartusek I agree that this is a useful addition. Currently the only reason I have not implemented this library is that I have no way to provide this context when the library opens. So I get a list of unrelated gifs by default, instead of a list of gifs related to the chat message the user had already started typing. Please allow this functionality to exist or for a developer to at least have a way to override the default text so we can accomplish it. Thank you.

@maiconcarraro
Copy link

@MrBartusek I can share an use case from our product, we have creators that upload to Tenor their own gallery of gifs, and all of their gifs have a common tag that is related to our product's name, so the initial search for the users is using this same common tag so they can easily pick without having to search... but they can still search if they want, just a matter of UX.

We're migrating from Giphy to Tenor, let me know if there is a better approach if you don't agree to the initial search query.

@jaxomlotus
Copy link

jaxomlotus commented Sep 17, 2024

@MrBartusek I had a similar use case above. And as Giphy has now introduce a pricing plan, I suspect lots of people will be migrating to Tenor, with similar requests.

For what it's worth, if the sole reason for not implementing this is concern over where you can post attribution for Tenor, just append a powered by Tenor statement right under the search input, as in @manoelneto screenshot above, or rely on the user to figure out where to post attribution and stay compliant. It will still look acceptable.

@TheNoobiCat
Copy link

Yeah, maybe a small label with "Tenor Results" under the search bar could work. Or, as @jaxomlotus said, just require the users to manage attribution.

@maiconcarraro
Copy link

maiconcarraro commented Sep 17, 2024

I didn't find in their terms, so suggesting here (lmk if it's agains't), but you can still show "Search Tenor" and allow initial search query to render/filter the relevant initial gifs, but once the user start typing that's what takes precedence.

Initial search query is not the same as initial input value IMHO, for our product we only need to filter initial results and not control the input value itself.

Copy link
Owner

@MrBartusek MrBartusek left a comment

Choose a reason for hiding this comment

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

Hey! Apologies for the delay in reviewing this PR. This should have been done faster, and I'll make an effort to complete future reviews more quickly.

yarn.lock Outdated Show resolved Hide resolved
src/GifPickerReact.tsx Outdated Show resolved Hide resolved
@MrBartusek
Copy link
Owner

@jaxomlotus @TheNoobiCat For the attribution concerns - according to the atribution guide I wouldn't worry too much about it

Search Tenor. Use this attribution as the placeholder text in your search box.

We do have a placeholder and the fact that we put some default text in the search box on render doesn't change that.

@MrBartusek MrBartusek added the enhancement New feature or request label Sep 17, 2024
@maiconcarraro
Copy link

@MrBartusek I sent a different PR based on my original suggestion in case you agree/prefer the approach #33

src/GifPickerReact.tsx Outdated Show resolved Hide resolved
Comment on lines 110 to 116
export const InitialSearchTerm = {
...Home,
args: {
...Home.args,
initialSearchTerm: 'love'
}
};
Copy link
Owner

Choose a reason for hiding this comment

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

We already have Search story and that's just a duplicate. Please change Search story to use initialSearchTerm instead of user event rather than create new one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all stories already have the initial search term, I'll just remove this.

src/stories/GifPicker.stories.tsx Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@MrBartusek MrBartusek changed the title Adding controlled picker Context Add initialSearchTerm prop Sep 18, 2024
src/GifPickerReact.tsx Outdated Show resolved Hide resolved
@MrBartusek
Copy link
Owner

@manoelneto you have skipped some of my comments

@MrBartusek
Copy link
Owner

@manoelneto please also change Search story to use this new prop

@manoelneto
Copy link
Contributor Author

@manoelneto you have skipped some of my comments

done. sorry about that.

@manoelneto
Copy link
Contributor Author

@manoelneto please also change Search story to use this new prop

it's already done

Copy link
Owner

@MrBartusek MrBartusek left a comment

Choose a reason for hiding this comment

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

LGTM, i will merge this and publish new version this weekend probably

@jaxomlotus

This comment was marked as off-topic.

@TheNoobiCat

This comment was marked as off-topic.

@MrBartusek MrBartusek merged commit 95c5dff into MrBartusek:master Sep 21, 2024
2 checks passed
@MrBartusek
Copy link
Owner

Thank you!

@MrBartusek
Copy link
Owner

I've just published v1.4.0 please let me know if it works!

@jaxomlotus
Copy link

jaxomlotus commented Sep 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants