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

Signup: Use new search for domains signup #51718

Merged
merged 7 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions client/components/domains/register-domain-step/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
} from 'calypso/lib/domains';
import { domainAvailability } from 'calypso/lib/domains/constants';
import { getAvailabilityNotice } from 'calypso/lib/domains/registration/availability-messages';
import Search from 'calypso/components/search';
import Search from '@automattic/search';
Copy link
Member

Choose a reason for hiding this comment

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

Let's move this to external dependencies.

import DomainRegistrationSuggestion from 'calypso/components/domains/domain-registration-suggestion';
import DomainTransferSuggestion from 'calypso/components/domains/domain-transfer-suggestion';
import DomainSkipSuggestion from 'calypso/components/domains/domain-skip-suggestion';
Expand Down Expand Up @@ -445,7 +445,7 @@ class RegisterDomainStep extends React.Component {
<StickyPanel className={ searchBoxClassName }>
<CompactCard className="register-domain-step__search-card">
<Search
additionalClasses={ this.state.clickedExampleSuggestion ? 'is-refocused' : undefined }
className={ this.state.clickedExampleSuggestion ? 'is-refocused' : undefined }
Copy link
Member

Choose a reason for hiding this comment

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

There seems to be a initialValue prop that the search package doesn't support.

Also, we're passing a ref, but we also create new refs in our component. Could that cause a regression?

Copy link
Contributor Author

@sarayourfriend sarayourfriend Apr 7, 2021

Choose a reason for hiding this comment

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

There seems to be a initialValue prop that the search package doesn't support.

Ah yes I think this was renamed to defaultValue, good catch, thanks.

Also, we're passing a ref, but we also create new refs in our component. Could that cause a regression?

What do you mean by this? The ref that is passed get's handled by useImperativeHandle and duplicates the methods that were being used on the old component by the contexts where refs were being passed (mostly focus to be honest).

Copy link
Member

Choose a reason for hiding this comment

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

Scratch that, I don't think it's a concern anyway.

autoFocus // eslint-disable-line jsx-a11y/no-autofocus
delaySearch={ true }
delayTimeout={ 1000 }
Expand Down
13 changes: 12 additions & 1 deletion packages/search/src/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
import { useI18n } from '@wordpress/react-i18n';
import classNames from 'classnames';
import React, { useEffect } from 'react';
import type { Ref, ChangeEvent, FocusEvent, FormEvent, KeyboardEvent, MouseEvent } from 'react';
import type {
ReactNode,
Ref,
ChangeEvent,
FocusEvent,
FormEvent,
KeyboardEvent,
MouseEvent,
} from 'react';
import { debounce } from 'lodash';

/**
Expand Down Expand Up @@ -50,6 +58,7 @@ type Props = {
autoFocus?: boolean;
className?: string;
compact?: boolean;
children?: ReactNode;
defaultIsOpen?: boolean;
defaultValue?: string;
delaySearch?: boolean;
Expand Down Expand Up @@ -111,6 +120,7 @@ type ImperativeHandle = {

const InnerSearch = (
{
children,
delaySearch = false,
disabled = false,
pinned = false,
Expand Down Expand Up @@ -428,6 +438,7 @@ const InnerSearch = (
{ renderStylingDiv() }
</form>
{ shouldRenderRightOpenIcon ? renderOpenIcon() : renderCloseButton() }
{ children }
</div>
);
};
Expand Down