Skip to content

fix(input): string values are emitted - #27226

Merged
liamdebeasi merged 2 commits into
mainfrom
FW-4079
Apr 18, 2023
Merged

liamdebeasi merged 2 commits into
mainfrom
FW-4079

Conversation

@liamdebeasi

@liamdebeasi liamdebeasi commented Apr 18, 2023 •

Copy link
Copy Markdown
Contributor

Issue number: N/A


What is the current behavior?

The InputChangeEventDetail and InputInputEventDetail interfaces were updated to add a number type to the value key: #26176

This was done to align with the value property on ion-input which allows for strings and numbers. However, this is incorrect as the value emitted is always forced to a string:

const newValue = value == null ? value : value.toString();

We likely copied the the type definition for the value prop not realizing that number values are never emitted.

What is the new behavior?

  • The InputChangeEventDetail and InputInputEventDetail interfaces no longer have the number type
  • The value passed to ionInput is converted to a string. (This isn't really needed since the native <input> element will have a type of string when the user types, but I added it for consistency with the ionChange emission).
  • Added a code comment to highlight this behavior

Does this introduce a breaking change?

  • Yes
  • No

Note: This is not a breaking change because number values were never emitted in the first place.

Other information

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@liamdebeasi
liamdebeasi marked this pull request as ready for review April 18, 2023 12:46
@liamdebeasi
liamdebeasi requested a review from a team as a code owner April 18, 2023 12:46
this.ionInput.emit({ value, event });

// Checks for both null and undefined values
const newValue = value == null ? value : value.toString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The type interface only allows string | null, no undefined, so should we return null instead of value on the left half? Or should the type be updated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand. The interface for InputInputEventDetail has value?: string | null where the ? indicates the value can be undefined.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, you're right, I missed that 🤪

@liamdebeasi
liamdebeasi added this pull request to the merge queue Apr 18, 2023
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 18, 2023
github-merge-queue Bot pushed a commit that referenced this pull request Apr 18, 2023
Issue number: N/A

---------

<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->

<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

The `InputChangeEventDetail` and `InputInputEventDetail` interfaces were
updated to add a number type to the value key:
#26176

This was done to align with the value property on ion-input which allows
for strings and numbers. However, this is incorrect as the value emitted
is always forced to a string:
https://github.com/ionic-team/ionic-framework/blob/c9bddbdb4cd45fea6a7a57d9427a0294db0b4027/core/src/components/input/input.tsx#L416


We likely copied the the type definition for the `value` prop not
realizing that number values are never emitted.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- The `InputChangeEventDetail` and `InputInputEventDetail` interfaces no
longer have the `number` type
- The value passed to `ionInput` is converted to a string. (This isn't
really needed since the native `<input>` element will have a type of
string when the user types, but I added it for consistency with the
`ionChange` emission).
- Added a code comment to highlight this behavior

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

Note: This is not a breaking change because `number` values were never
emitted in the first place.

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
@liamdebeasi
liamdebeasi added this pull request to the merge queue Apr 18, 2023
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 18, 2023
github-merge-queue Bot pushed a commit that referenced this pull request Apr 18, 2023
Issue number: N/A

---------

<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->

<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

The `InputChangeEventDetail` and `InputInputEventDetail` interfaces were
updated to add a number type to the value key:
#26176

This was done to align with the value property on ion-input which allows
for strings and numbers. However, this is incorrect as the value emitted
is always forced to a string:
https://github.com/ionic-team/ionic-framework/blob/c9bddbdb4cd45fea6a7a57d9427a0294db0b4027/core/src/components/input/input.tsx#L416


We likely copied the the type definition for the `value` prop not
realizing that number values are never emitted.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- The `InputChangeEventDetail` and `InputInputEventDetail` interfaces no
longer have the `number` type
- The value passed to `ionInput` is converted to a string. (This isn't
really needed since the native `<input>` element will have a type of
string when the user types, but I added it for consistency with the
`ionChange` emission).
- Added a code comment to highlight this behavior

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

Note: This is not a breaking change because `number` values were never
emitted in the first place.

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
@liamdebeasi
liamdebeasi added this pull request to the merge queue Apr 18, 2023
Merged via the queue into main with commit cdb0627 Apr 18, 2023
@liamdebeasi
liamdebeasi deleted the FW-4079 branch April 18, 2023 15:16
liamdebeasi added a commit that referenced this pull request Apr 19, 2023
Issue number: N/A

---------

<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->

<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

The `InputChangeEventDetail` and `InputInputEventDetail` interfaces were
updated to add a number type to the value key:
#26176

This was done to align with the value property on ion-input which allows
for strings and numbers. However, this is incorrect as the value emitted
is always forced to a string:
https://github.com/ionic-team/ionic-framework/blob/c9bddbdb4cd45fea6a7a57d9427a0294db0b4027/core/src/components/input/input.tsx#L416


We likely copied the the type definition for the `value` prop not
realizing that number values are never emitted.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- The `InputChangeEventDetail` and `InputInputEventDetail` interfaces no
longer have the `number` type
- The value passed to `ionInput` is converted to a string. (This isn't
really needed since the native `<input>` element will have a type of
string when the user types, but I added it for consistency with the
`ionChange` emission).
- Added a code comment to highlight this behavior

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

Note: This is not a breaking change because `number` values were never
emitted in the first place.

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants