[ui][typeahead] allow typeahead to be cleared

pull/459/head
Yangshun Tay 2 years ago
parent a103879b5c
commit f7ff20bb22

@ -5,4 +5,7 @@ module.exports = {
tsconfigRootDir: __dirname, tsconfigRootDir: __dirname,
project: ['./tsconfig.json'], project: ['./tsconfig.json'],
}, },
rules: {
'@typescript-eslint/ban-ts-comment': 0,
},
}; };

@ -97,6 +97,7 @@ function FullTimeJobFields() {
<div className="mb-5 grid grid-cols-2 space-x-3"> <div className="mb-5 grid grid-cols-2 space-x-3">
<div> <div>
<JobTitlesTypeahead <JobTitlesTypeahead
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => onSelect={({ value }) =>
setValue(`background.experiences.0.title`, value) setValue(`background.experiences.0.title`, value)
} }
@ -104,6 +105,7 @@ function FullTimeJobFields() {
</div> </div>
<div> <div>
<CompaniesTypeahead <CompaniesTypeahead
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => onSelect={({ value }) =>
setValue(`background.experiences.0.companyId`, value) setValue(`background.experiences.0.companyId`, value)
} }
@ -178,6 +180,7 @@ function InternshipJobFields() {
<div className="mb-5 grid grid-cols-2 space-x-3"> <div className="mb-5 grid grid-cols-2 space-x-3">
<div> <div>
<JobTitlesTypeahead <JobTitlesTypeahead
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => onSelect={({ value }) =>
setValue(`background.experiences.0.title`, value) setValue(`background.experiences.0.title`, value)
} }
@ -185,6 +188,7 @@ function InternshipJobFields() {
</div> </div>
<div> <div>
<CompaniesTypeahead <CompaniesTypeahead
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => onSelect={({ value }) =>
setValue(`background.experiences.0.companyId`, value) setValue(`background.experiences.0.companyId`, value)
} }

@ -70,6 +70,7 @@ function FullTimeOfferDetailsForm({
<div> <div>
<JobTitlesTypeahead <JobTitlesTypeahead
required={true} required={true}
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => onSelect={({ value }) =>
setValue(`offers.${index}.offersFullTime.title`, value) setValue(`offers.${index}.offersFullTime.title`, value)
} }
@ -89,6 +90,7 @@ function FullTimeOfferDetailsForm({
<div> <div>
<CompaniesTypeahead <CompaniesTypeahead
required={true} required={true}
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => onSelect={({ value }) =>
setValue(`offers.${index}.companyId`, value) setValue(`offers.${index}.companyId`, value)
} }
@ -277,6 +279,7 @@ function InternshipOfferDetailsForm({
<div> <div>
<JobTitlesTypeahead <JobTitlesTypeahead
required={true} required={true}
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => onSelect={({ value }) =>
setValue(`offers.${index}.offersIntern.title`, value) setValue(`offers.${index}.offersIntern.title`, value)
} }
@ -287,6 +290,7 @@ function InternshipOfferDetailsForm({
<div> <div>
<CompaniesTypeahead <CompaniesTypeahead
required={true} required={true}
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => onSelect={({ value }) =>
setValue(`offers.${index}.companyId`, value) setValue(`offers.${index}.companyId`, value)
} }

@ -97,6 +97,7 @@ export default function LandingComponent({
isLabelHidden={true} isLabelHidden={true}
value={company} value={company}
onSelect={(value) => { onSelect={(value) => {
// @ts-ignore TODO(questions): handle potentially null value.
handleChangeCompany(value); handleChangeCompany(value);
}} }}
/> />
@ -105,6 +106,7 @@ export default function LandingComponent({
isLabelHidden={true} isLabelHidden={true}
value={location} value={location}
onSelect={(value) => { onSelect={(value) => {
// @ts-ignore TODO(questions): handle potentially null value.
handleChangeLocation(value); handleChangeLocation(value);
}} }}
/> />

@ -81,6 +81,7 @@ export default function ContributeQuestionForm({
<LocationTypeahead <LocationTypeahead
required={true} required={true}
onSelect={(option) => { onSelect={(option) => {
// @ts-ignore TODO(questions): handle potentially null value.
field.onChange(option.value); field.onChange(option.value);
}} }}
{...field} {...field}
@ -119,6 +120,7 @@ export default function ContributeQuestionForm({
render={({ field }) => ( render={({ field }) => (
<CompanyTypeahead <CompanyTypeahead
required={true} required={true}
// @ts-ignore TODO(questions): handle potentially null value.
onSelect={({ id }) => { onSelect={({ id }) => {
field.onChange(id); field.onChange(id);
}} }}
@ -134,6 +136,7 @@ export default function ContributeQuestionForm({
<RoleTypeahead <RoleTypeahead
required={true} required={true}
onSelect={(option) => { onSelect={(option) => {
// @ts-ignore TODO(questions): handle potentially null value.
field.onChange(option.value); field.onChange(option.value);
}} }}
{...field} {...field}

@ -43,6 +43,7 @@ export default function CreateQuestionEncounterForm({
isLabelHidden={true} isLabelHidden={true}
placeholder="Other company" placeholder="Other company"
suggestedCount={3} suggestedCount={3}
// @ts-ignore TODO(questions): handle potentially null value.
onSelect={({ value: company }) => { onSelect={({ value: company }) => {
setSelectedCompany(company); setSelectedCompany(company);
}} }}
@ -59,6 +60,7 @@ export default function CreateQuestionEncounterForm({
isLabelHidden={true} isLabelHidden={true}
placeholder="Other location" placeholder="Other location"
suggestedCount={3} suggestedCount={3}
// @ts-ignore TODO(questions): handle potentially null value.
onSelect={({ value: location }) => { onSelect={({ value: location }) => {
setSelectedLocation(location); setSelectedLocation(location);
}} }}
@ -75,6 +77,7 @@ export default function CreateQuestionEncounterForm({
isLabelHidden={true} isLabelHidden={true}
placeholder="Other role" placeholder="Other role"
suggestedCount={3} suggestedCount={3}
// @ts-ignore TODO(questions): handle potentially null value.
onSelect={({ value: role }) => { onSelect={({ value: role }) => {
setSelectedRole(role); setSelectedRole(role);
}} }}

@ -8,7 +8,7 @@ type Props = Readonly<{
disabled?: boolean; disabled?: boolean;
errorMessage?: string; errorMessage?: string;
isLabelHidden?: boolean; isLabelHidden?: boolean;
onSelect: (option: TypeaheadOption) => void; onSelect: (option: TypeaheadOption | null) => void;
placeHolder?: string; placeHolder?: string;
required?: boolean; required?: boolean;
}>; }>;

@ -7,7 +7,7 @@ import { JobTitleLabels } from './JobTitles';
type Props = Readonly<{ type Props = Readonly<{
disabled?: boolean; disabled?: boolean;
isLabelHidden?: boolean; isLabelHidden?: boolean;
onSelect: (option: TypeaheadOption) => void; onSelect: (option: TypeaheadOption | null) => void;
placeHolder?: string; placeHolder?: string;
required?: boolean; required?: boolean;
}>; }>;

@ -37,12 +37,14 @@ export default function OffersHomePage() {
<JobTitlesTypeahead <JobTitlesTypeahead
isLabelHidden={true} isLabelHidden={true}
placeHolder="Software Engineer" placeHolder="Software Engineer"
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => setjobTitleFilter(value)} onSelect={({ value }) => setjobTitleFilter(value)}
/> />
<span>in</span> <span>in</span>
<CompaniesTypeahead <CompaniesTypeahead
isLabelHidden={true} isLabelHidden={true}
placeHolder="All Companies" placeHolder="All Companies"
// @ts-ignore TODO(offers): handle potentially null value.
onSelect={({ value }) => setCompanyFilter(value)} onSelect={({ value }) => setCompanyFilter(value)}
/> />
</div> </div>

@ -325,6 +325,7 @@ export default function QuestionsBrowsePage() {
isLabelHidden={true} isLabelHidden={true}
placeholder="Search companies" placeholder="Search companies"
onSelect={(option) => { onSelect={(option) => {
// @ts-ignore TODO(questions): handle potentially null value.
onOptionChange({ onOptionChange({
...option, ...option,
checked: true, checked: true,
@ -357,6 +358,7 @@ export default function QuestionsBrowsePage() {
isLabelHidden={true} isLabelHidden={true}
placeholder="Search roles" placeholder="Search roles"
onSelect={(option) => { onSelect={(option) => {
// @ts-ignore TODO(questions): handle potentially null value.
onOptionChange({ onOptionChange({
...option, ...option,
checked: true, checked: true,
@ -414,6 +416,7 @@ export default function QuestionsBrowsePage() {
isLabelHidden={true} isLabelHidden={true}
placeholder="Search locations" placeholder="Search locations"
onSelect={(option) => { onSelect={(option) => {
// @ts-ignore TODO(offers): fix potentially empty value.
onOptionChange({ onOptionChange({
...option, ...option,
checked: true, checked: true,

@ -34,7 +34,7 @@ type Props = Readonly<{
value: string, value: string,
event: React.ChangeEvent<HTMLInputElement>, event: React.ChangeEvent<HTMLInputElement>,
) => void; ) => void;
onSelect: (option: TypeaheadOption) => void; onSelect: (option: TypeaheadOption | null) => void;
options: ReadonlyArray<TypeaheadOption>; options: ReadonlyArray<TypeaheadOption>;
textSize?: TypeaheadTextSize; textSize?: TypeaheadTextSize;
value?: TypeaheadOption; value?: TypeaheadOption;
@ -102,10 +102,6 @@ export default function Typeahead({
// @ts-ignore // @ts-ignore
value={value} value={value}
onChange={(newValue) => { onChange={(newValue) => {
if (newValue == null) {
return;
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
onSelect(newValue as TypeaheadOption); onSelect(newValue as TypeaheadOption);

Loading…
Cancel
Save