Repository navigation
feat(input, textarea): ionInput and ionChange pass event and value - #26176
Merged
Merged
Conversation
averyrousseau
approved these changes
Oct 28, 2022
sean-perkins
approved these changes
Oct 31, 2022
sean-perkins
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me!
One small suggestion on the breaking change wording.
Co-authored-by: Sean Perkins <[email protected]>
Co-authored-by: Sean Perkins <[email protected]>
|
I have an question - why eea6ba9#diff-5172cfa7e4dd36c59ff7084a0fcea91a7b910956c334673bb22eb138f84a8bda Value of HTMLInputElement may only be a This change hasn't been described in this PR or Ionic 7 migration docs, but in effect when using TypeScript in event handlers there must be added extra type check |
Contributor
Author
|
This looks like a typo. I created a PR to fix this here: #27226 |
1 of 2 tasks
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. -->
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 Thank you 👍 |
liamdebeasi
added 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
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. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request checklist
Please check if your PR fulfills the following requirements:
ionic-docsrepo, in a separate PR. See the contributing guide for details.npm run build) was run locally and any changes were pushednpm run lint) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue URL: N/A Internal Ticket
As a result of our recent
ionChangerevisions, the team noted that theionInputandionChangepayloads were inconsistent.ionChangeevent detail has an object containing the value, but theionInputevent detail has the native event. We were concerned that those switching fromionChangetoionInputmay find this migration confusing due to the different information available across events.What is the new behavior?
ionInputandionChangeforion-inputandion-textareanow have adetailpayload of an object that contains the current componentvalueand the native event (if one exists).ChangeEventDetailandInputEventDetailinterfaces. I opted to keep them separate for now despite them having the same contents. This was done to make the interfaces easier to reason above. We can consolidate them in the future if needed.InputCustomEventandTextareaCustomEventto use a generic fordetailso that developers can specify either the input or the change event detail payload. I made it default to the{Input,Textarea}ChangeEventDetailinterface to avoid another breaking change, but I am open to discussing this. This change is not needed at the moment, but it will be needed in case theInputEventDetailorChangeEventDetailinterfaces need to diverge again in the future.Does this introduce a breaking change?
Other information