Skip to content

Commit d16b18d

Browse files
Fix input value on select (GH-62)
2 parents 5e71f9a + 9e07e9f commit d16b18d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.3.2",
2+
"version": "0.3.3",
33
"name": "antd-phone-input",
44
"description": "Advanced, highly customizable phone input component for Ant Design.",
55
"keywords": [

src/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ const PhoneInput = ({
215215
suffixIcon={null}
216216
value={selectValue}
217217
open={disableDropdown ? false : undefined}
218-
onSelect={(selectedOption, {key: mask}) => {
218+
onSelect={(selectedOption, {key}) => {
219+
const [_, mask] = key.split("_");
219220
if (selectValue === selectedOption) return;
220221
const selectedCountryCode = selectedOption.slice(0, 2);
221222
const formattedNumber = displayFormat(cleanInput(mask, mask).join(""));
@@ -241,8 +242,8 @@ const PhoneInput = ({
241242
>
242243
{countriesList.map(([iso, name, dial, mask]) => (
243244
<Select.Option
244-
key={iso + mask}
245245
value={iso + dial}
246+
key={`${iso}_${mask}`}
246247
label={<div className={`flag ${iso}`}/>}
247248
children={<div className="ant-phone-input-select-item">
248249
<div className={`flag ${iso}`}/>

0 commit comments

Comments
 (0)