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(quick-search): Quick Search Navigation #3622

Merged
merged 9 commits into from
Aug 23, 2024

Conversation

shahzadaziz
Copy link
Contributor

@shahzadaziz shahzadaziz commented Aug 23, 2024

This fix adds logic to skip keyboard focus handlers for New Quick Search components

@shahzadaziz shahzadaziz requested a review from a team as a code owner August 23, 2024 18:10
@@ -613,7 +609,12 @@ function makeSelectable(BaseTable) {
isTargetSlider = event => event.target?.role === 'slider';

// Workaround for focus conflicting with Blueprint components in Search Quick Filters, not needed once Blueprint table is integrated
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we update this comment, maybe put the comments directly above each case in isTargetQuickSearch

JChan106
JChan106 previously approved these changes Aug 23, 2024
Copy link
Contributor

@JChan106 JChan106 left a comment

Choose a reason for hiding this comment

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

lgtm

JChan106
JChan106 previously approved these changes Aug 23, 2024
// Workaround for focus conflicting with Blueprint components in
// QuickSearch result, recent items and Quick Filters
isTargetQuickSearch = event =>
(event.target?.className &&
Copy link
Contributor

Choose a reason for hiding this comment

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

🔧 this function feels hard to follow as there are multiple targets all && and || together. Can we use guard statements or variables to hold context as to what the selectors are?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TylerGauntlett good suggestion.


if (
className &&
(className.includes('quickSearchRecentItem') || className.includes('quickSearchResultItem'))
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ optional chaining offer any value here? className?.includes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure it does since we are checking for className.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess i mean dropping the className check and using optional chaining in both

TylerGauntlett
TylerGauntlett previously approved these changes Aug 23, 2024

const { className, dataset } = event.target;

if (
Copy link
Contributor

Choose a reason for hiding this comment

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

🔧 might be worth adding comments over each of these if blocks detailing exactly what its targeting. These class names might be a easy enough to put together with the comment overtop the function but the dataset strategy below becomes much harder

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like this

        if (!event.target) {
            return false;
        }

        const { className, dataset } = event.target;

        // QuickSearch Recent Item
        if (className?.includes('quickSearchRecentItem')) {
            return true;
        }

        // Quick Search Result Item
        if (className?.includes('quickSearchResultItem')) {
            return true;
        }

        // Blueprint's <FilterChip>
        if (dataset && ('radixCollectionItem' in dataset)) {
            return true;
        }

        // Blueprint's <SmallList>
        if (dataset && 'bpSmallListItem' in dataset) {
            return true;
        }

        return false;

@mergify mergify bot merged commit b814223 into box:master Aug 23, 2024
6 checks passed
@shahzadaziz shahzadaziz deleted the quick-search-focus-fix branch August 23, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants