Skip to content

fix(picker-column): prevSelected is set to the correct value - #27458

Merged
thetaPC merged 5 commits into
mainfrom
FW-4126
May 16, 2023
Merged

thetaPC merged 5 commits into
mainfrom
FW-4126

Conversation

@thetaPC

@thetaPC thetaPC commented May 11, 2023 •

Copy link
Copy Markdown
Contributor

Issue number: resolves #21764


What is the current behavior?

The prevSelected returns the same value as selectedIndex.

When a user has selected the first option then the second:

  • prevSelected returns 1
  • selectedIndex returns 1

What is the new behavior?

The prevSelected returns the index of the last selected option.

When a user has selected the first option then the second:

  • prevSelected returns 0
  • selectedIndex returns 1

Does this introduce a breaking change?

  • Yes
  • No

Other information

Read the comment below regarding toHaveReceivedEventDetail.

@bolt-new-by-stackblitz

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the package: core @ionic/core package label May 11, 2023
Comment on lines +42 to +43
expect(ionPickerColChangeEvent.events[0].detail.prevSelected).toBe(0);
expect(ionPickerColChangeEvent.events[0].detail.selectedIndex).toBe(1);

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.

Decided to not use toHaveReceivedEventDetail because it returns the entire col object. The test only needs to test the prevSelected and selectedIndex value.

@thetaPC
thetaPC marked this pull request as ready for review May 11, 2023 20:19
@thetaPC
thetaPC requested a review from a team as a code owner May 11, 2023 20:19

@liamdebeasi liamdebeasi left a comment

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.

Great job! One test change below, but otherwise the code looks good.

Also small nitpick: Can we change "returns" to "is set to" in the PR title? IMO "returns" implies prevSelected is a function.


await ionPickerDidPresent.next();

secondOption.click();

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.

Suggested change
secondOption.click();
await secondOption.click();

click is asynchronous

@thetaPC thetaPC changed the title fix(picker-column): prevSelected returns the correct value fix(picker-column): prevSelected is set to the correct value May 16, 2023
@thetaPC
thetaPC added this pull request to the merge queue May 16, 2023
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 16, 2023
@thetaPC
thetaPC added this pull request to the merge queue May 16, 2023
Merged via the queue into main with commit 9dc126d May 16, 2023
@thetaPC
thetaPC deleted the FW-4126 branch May 16, 2023 16:52
brandyscarney pushed a commit that referenced this pull request May 22, 2023
Issue number: resolves #21764 

---------

<!-- 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 `prevSelected` returns the same value as `selectedIndex`.

When a user has selected the first option then the second:
- `prevSelected` returns `1`
- `selectedIndex` returns `1`

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

The `prevSelected` returns the index of the last selected option.

When a user has selected the first option then the second:
- `prevSelected` returns `0`
- `selectedIndex` returns `1`

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- 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. -->

Read the comment below regarding `toHaveReceivedEventDetail`.
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.

bug: picker column prevSelect is always the same as selectedIndex

2 participants