Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datetime): allow disabling datetime with prefer-wheel #28511

Merged
merged 25 commits into from
Nov 22, 2023
Merged

Conversation

mapsandapps
Copy link
Contributor

Issue number: Internal


What is the current behavior?

It is possible to navigate the columns of a disabled Datetime with prefer-wheel via the keyboard.

disabled-bug.mov

What is the new behavior?

  • Picker Column Internal has a disabled state that disables the full column
  • When a Datetime is disabled with prefer-wheel, the columns in the Datetime will be disabled
  • It is no longer possible to navigate the wheels in a disabled Datetime via the keyboard

Comparison of native & Ionic components:

Screenshot 2023-11-10 at 10 58 25 AM

Does this introduce a breaking change?

  • Yes
  • No

@github-actions github-actions bot added the package: core @ionic/core package label Nov 10, 2023
@mapsandapps mapsandapps marked this pull request as ready for review November 13, 2023 14:17
core/src/components/datetime/test/disabled/datetime.e2e.ts Outdated Show resolved Hide resolved
});
await page.waitForChanges();

await expect(disabledColumn).toHaveScreenshot(screenshot('picker-internal-disabled-column'));
Copy link
Contributor

Choose a reason for hiding this comment

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

We should dig into this test more. Playwright is already reporting it as flaky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still flaking. I can't reproduce locally 😕

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try loading the test with the value already set? The problem might be that Playwright isn't waiting for the scroll to finish before taking a screenshot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 4661667 and I also made a change in 7a3771a that hopefully will help.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that we should try loading the picker with value="11" already set. So you should be able to do value="11" here:

<ion-picker-column-internal id="column-disabled" value="12" disabled></ion-picker-column-internal>
and then remove this line:

For 7a3771a this causes a regression where the selected item is no longer highlighted when the picker column is disabled. You can see this at src/components/picker-column-internal/test/disabled on MD mode. The "11" option in "Column disabled" is no longer highlighted in blue.

According to your comment in https://github.com/ionic-team/ionic-framework/pull/28511/files#diff-5e7b473017ccb3a8be0fa9c7c9d8e1fc393b64ddfe719d5f3274e212ba09b3fdR416 this item should be highlighted blue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand how setting the value directly changes anything for the scrolling if the items don't get set until the script? It can't scroll until the items are there any more than it can scroll if the value isn't there, right? 🤔

My comment about the active item was referring to the fact that the item should be scrolled to. But from looking at our other disabled md components, it does look like it should be blue as well. I'll revert that change, but I don't know what's causing it to be blue sometimes and gray others in md mode on Safari.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Also, I added a screenshot for the disabled calendar wheel to capture that intended behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand how setting the value directly changes anything for the scrolling if the items don't get set until the script? It can't scroll until the items are there any more than it can scroll if the value isn't there, right?

The issue that I raised was the value was being set after the component loaded: https://github.com/ionic-team/ionic-framework/pull/28511/files/b7e42befeabbbb96044bbaa0aeb6ba6668baa547#diff-875e8dba2863da31c37c64b445f9c01418f2ee542625acf814f7a8cab7464b19R174

Your old test loaded the picker with value="12". The picker spends time scrolling to value 12. The test then set the value to 11, so the picker then needed to spend additional time scrolling to value 11. This additional value update can take a few hundred ms especially on CI.

By setting up the test with the correct configuration on load we a) reduce the run time of the test and b) reduce the likelihood of flaky tests.

Copy link
Contributor

@sean-perkins sean-perkins left a comment

Choose a reason for hiding this comment

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

Behavior looks great locally 👍 I had one suggestion for organizing the styles, but everything else looks good to me. Great work!

Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

The behavior looks good now, though there are some places where the code can be cleaned up.

class={createColorClasses(color, {
[mode]: true,
['picker-column-active']: isActive,
['picker-column-disabled']: pickerDisabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

This class doesn't seem needed anymore. The only place it's used is in the CSS, and that could be swapped out for the [disabled] attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I went ahead and removed the .picker-item-disabled class while I was in there, by the same reasoning, even though it predates this PR.

Copy link
Contributor

@liamdebeasi liamdebeasi Nov 21, 2023

Choose a reason for hiding this comment

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

I was referring to picker-column-disabled not picker-item-disabled. The picker-column-disabled class was added in this PR.

edit: see below

Copy link
Contributor

Choose a reason for hiding this comment

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

Re-read this and looks like I misunderstood your original comment. All of that sounds good!

Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

I made one change in fab89a7

This test is not needed because we already have the following tests:

  1. A test to verify that datetime sets the disabled prop on columns correctly: https://github.com/ionic-team/ionic-framework/pull/28511/files#diff-68455eb0492521a5359f114d63eedc2c4d3731e47f7fa6f349ba54456bcc18a2
  2. A test to verify that a column renders correctly when disabled is set: https://github.com/ionic-team/ionic-framework/pull/28511/files#diff-875e8dba2863da31c37c64b445f9c01418f2ee542625acf814f7a8cab7464b19

Datetime does not apply any disabled-specific visual styles for the wheel picker. It does apply pointer-events: none, but the test I removed was not checking that.

The rest of this is good to go. Great work!

@liamdebeasi liamdebeasi added this pull request to the merge queue Nov 22, 2023
Merged via the queue into main with commit 01130e1 Nov 22, 2023
46 checks passed
@liamdebeasi liamdebeasi deleted the FW-5408 branch November 22, 2023 16:18
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.

4 participants