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

fix(tag mode): strict selection behavior to only allow picking from suggestions #2278

Merged
merged 4 commits into from
Feb 8, 2024

Conversation

siddharthlatest
Copy link
Member

@siddharthlatest siddharthlatest commented Jan 3, 2024

This PR fixes a behavior for tag mode where a user setting an input value that is not part of suggestions is not allowed when strictSelection mode is set.

Components this applies to:

For code review, the main changes are in the first two commits: DataSearch code change, SearchBox code change

This change is available in reactivesearch-vue v1.35.3. The changes in this PR should be cherry-picked to Vue v3 version and React v4 versions.

@github-actions github-actions bot added the vue label Jan 3, 2024
@siddharthlatest siddharthlatest changed the title fix(strict selection): fix(tag mode): strict selection behavior to only allow picking from suggestions Jan 3, 2024
Comment on lines 598 to 604
if (props.strictSelection && props.autosuggest) {
if (cause === causes.SUGGESTION_SELECT || props.value !== undefined) {
this.updateQueryHandler(props.componentId, queryHandlerValue, props);
} else if (this.currentValue !== '') {
} else if (this.currentValue !== '' && !props.strictSelection) {
this.setValue('', true);
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

:598 already checks for strictSelection prop which makes the check for strictSelection at L:608 unreachable

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 seeing a check that would make it unreachable. At L598, the check is for isTagsMode

Comment on lines +814 to +817
this.isSuggestionSelected = true;
setTimeout(() => {
this.isSuggestionSelected = false;
}, 50);
Copy link
Member

Choose a reason for hiding this comment

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

@siddharthlatest Can you explain the reason for async toggle of isSuggestionSelected?

Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes a side effect I am observing with two calls being made to this.setValue otherwise. See the use of the variable for the second place where the second call is being made from.

@mohdashraf010897 mohdashraf010897 merged commit cdf81ed into v3 Feb 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants