Skip to content

Commit

Permalink
fix: Upgrade usage of React-Select to support 5.x version
Browse files Browse the repository at this point in the history
  • Loading branch information
baumandm committed Jun 24, 2022
1 parent 2983240 commit 3dd1481
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,15 @@ export const FilterStack = ({
{!showAllFilters && (
<CreatableSelect
name="tags"
value=""
value={null}
options={selectOptions}
onChange={(e) => addFilter(filterKey, e.value)}
onChange={(e) => {
if (e) {
addFilter(filterKey, e.value);
}
}}
placeholder={`Select ${filterKey}...`}
aria-label={`Select ${filterKey}...`}
formatCreateLabel={(input) => getLabel(input)}
/>
)}
</SidebarStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export const InsightMetadataEditor = ({ insight, isNewInsight, form, templates,
inputId="insight-item-type"
options={itemTypeOptions}
onChange={(e) => {
onChange(e.value);
if (e) {
onChange(e.value);
}
}}
value={itemTypeOptions && value && itemTypeOptions.find((type) => type.name === value)}
styles={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export const InsightTeam = ({ insight, form }) => {
<CreatableSelect
inputId="team"
options={availableTeams}
onChange={(e) => onChange(e.value)}
onChange={(e) => {
if (e) {
onChange(e.value);
}
}}
value={{ value, label: value }}
styles={{
menu: (base) => ({ ...base, zIndex: 11 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,15 @@ export const FilterStack = ({
{!showAllFilters && (
<CreatableSelect
name="tags"
value=""
value={null}
options={selectOptions}
onChange={(e) => addFilter(filterKey, e.value)}
onChange={(e) => {
if (e) {
addFilter(filterKey, e.value);
}
}}
placeholder={`Select ${filterKey}...`}
aria-label={`Select ${filterKey}...`}
formatCreateLabel={(input) => getLabel(input)}
/>
)}
</SidebarStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export const InsightsSettings = ({ user, onSubmit, isSubmitting }: Props) => {
render={({ field: { onChange, value } }) => (
<Select
inputId="defaultTemplateId"
defaultValue={templateOptions.find((t) => t.value === defaultTemplateId)}
defaultValue={templateOptions.find((t) => t.value === defaultTemplateId) ?? { value: '' }}
options={templateOptions}
onChange={(e) => (e === null ? onChange('') : onChange(e.value))}
value={templateOptions && value && templateOptions.find((t) => t.value === value)}
onChange={(e) => (e == null || e == '' ? onChange('') : onChange(e.value))}
value={(templateOptions && value && templateOptions.find((t) => t.value === value)) ?? { value: '' }}
isClearable={true}
styles={{
menu: (base) => ({ ...base, zIndex: 11 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ export const ProfileSettings = ({ user, onSubmit, isSubmitting }: Props) => {
<CreatableSelect
inputId="team"
options={availableTeams}
onChange={(e) => onChange(e.value)}
onChange={(e) => {
if (e) {
onChange(e.value);
}
}}
value={{ value, label: value }}
styles={{
menu: (base) => ({ ...base, zIndex: 11 }),
Expand Down Expand Up @@ -336,10 +340,10 @@ export const ProfileSettings = ({ user, onSubmit, isSubmitting }: Props) => {
isMulti
isClearable
options={availableSkills}
onChange={(event: { value: string }[]) => {
onChange={(e) => {
let skills: string[] = [];
if (event != null) {
skills = event.map((e) => e.value.trim().toLowerCase().replace(/\s/g, '-'));
if (e != null) {
skills = e.map((v) => v.value.trim().toLowerCase().replace(/\s/g, '-'));
}
setValue('skills', skills);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export const SystemSettings = ({ user, onSubmit, isSubmitting }: Props) => {
inputId="locale"
defaultValue={{ value: detectedLocale, label: `Detected (${detectedLocale})` }}
options={localeOptions}
onChange={(e) => onChange(e.value)}
onChange={(e) => {
if (e) {
onChange(e.value);
}
}}
value={localeOptions && value && localeOptions.find((l) => l.value === value)}
placeholder={`Detected (${detectedLocale})`}
styles={{
Expand Down

0 comments on commit 3dd1481

Please sign in to comment.