Skip to content

fix(modal): set default text color - #27207

Merged
thetaPC merged 30 commits into
mainfrom
FW-3894
Apr 24, 2023
Merged

thetaPC merged 30 commits into
mainfrom
FW-3894

Conversation

@thetaPC

@thetaPC thetaPC commented Apr 14, 2023 •

Copy link
Copy Markdown
Contributor

What is the current behavior?

Occurs only when using modal with datetime: text does not update appropriately based on light or dark mode. For example, when using Ionic dark theme, the calendar days does not switch to white.

Issue URL: resolves #26060

What is the new behavior?

  • Text (days and time) changes to the text color set via light (default) or dark mode. The color change applies to days and time that are not selected: not the current day.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Recommendation:

  • Test both datetime and datetime-button

The bug originates when modal's content is not wrapped by ion-content and because the modal renders outside of <main />. Text color is passed to components properly inside main because main is rendered inside another ion-content. ion-content provides the correct text-color based on light or dark mode.

Example of text color working for modal when wrapped by ion-content:

<ion-modal trigger="open-modal">
    ...
  <ion-content class="ion-padding">
    <div>Hello world</div>
  </ion-content>
</ion-modal>

However, there are times that the modal does not require this wrap:

<ion-modal>
  <ion-datetime id="datetime"></ion-datetime>
</ion-modal>

The same bug would have occurred on popover if it wasn't for the fact that the component provides the text color.

@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 Apr 14, 2023
@thetaPC thetaPC changed the title fix(datetime): use $text-color for calendar day color fix(datetime): use $text-color for not-selected text Apr 14, 2023
@thetaPC thetaPC changed the title fix(datetime): use $text-color for not-selected text fix(datetime): use $text-color for normal text Apr 14, 2023
@thetaPC
thetaPC marked this pull request as ready for review April 14, 2023 19:56

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

Can we write a screenshot test for this?

@sean-perkins sean-perkins 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.

Changes look good! +1 to what Liam commented. The datetime basic test template already has an option for enabling dark mode and presenting the datetime in a modal. You may be able to use that test template to have a test that:

  • Enables dark mode
  • Presents the datetime in a modal
  • Captures a screenshot

@thetaPC
thetaPC requested a review from a team as a code owner April 18, 2023 17:00
@averyrousseau

averyrousseau commented Apr 19, 2023 •

Copy link
Copy Markdown
Contributor

So, the issue here occurs with more than just ion-datetime. If you put a random ion-text in the modal, for example, that also exhibits the incorrect text color when switching to dark mode. While I hadn't been able to isolate the exact cause when triaging the issue, I theorized about it here: #26060 (comment) Maybe a similar fix to what you have here should be applied to ion-modal instead? (I do think the new test covers our bases either way.)

@thetaPC

thetaPC commented Apr 19, 2023

Copy link
Copy Markdown
Contributor Author

So, the issue here occurs with more than just ion-datetime. If you put a random ion-text in the modal, for example, that also exhibits the incorrect text color when switching to dark mode. While I hadn't been able to isolate the exact cause when triaging the issue, I theorized about it here: #26060 (comment) Maybe a similar fix to what you have here should be applied to ion-modal instead? (I do think the new test covers our bases either way.)

Understood, I'll give modal a peek. Thank you!

@thetaPC thetaPC changed the title fix(datetime): use $text-color for normal text fix(datetime): set text color on modal Apr 19, 2023
@thetaPC

thetaPC commented Apr 19, 2023

Copy link
Copy Markdown
Contributor Author

@amandaejohnston if you're interested in the bug cause, I've updated the Other information section to include it.

@thetaPC
thetaPC marked this pull request as draft April 19, 2023 18:48
@thetaPC
thetaPC marked this pull request as ready for review April 20, 2023 20:02

@averyrousseau averyrousseau 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.

LGTM once the comments are addressed 👍


test('should not highlight a day until one is selected, with default-buttons', async ({ page }) => {
await testHighlight(page, 'custom-datetime');
await testHighlight(page, 'inline-datetime-no-value');

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
await testHighlight(page, 'inline-datetime-no-value');
await testHighlight(page, 'custom-datetime');

I'm assuming this was edited by mistake; this is meant to check a datetime with show-default-buttons set.

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.

It wasn't by mistake. I ended up passing a value to custom-datetime in order to solve the issue with the changing time that we saw via Zoom. Since these tests (test 1 and test 2) required a datetime that had no value then I ended up switching. However, I'll be reverting this file and moving the test to modal as suggested.

await page.goto('/src/components/datetime/test/basic');

const datetime = page.locator('#custom-datetime');
const datetime = page.locator('#inline-datetime-no-value');

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
const datetime = page.locator('#inline-datetime-no-value');
const datetime = page.locator('#custom-datetime');

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

The fix itself works well. Great job! A few comments on the tests.

@thetaPC thetaPC changed the title fix(datetime): set text color on modal fix(modal): set default text color Apr 21, 2023
@thetaPC
thetaPC requested a review from liamdebeasi April 21, 2023 20:03

@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 work!

@thetaPC
thetaPC added this pull request to the merge queue Apr 24, 2023
Merged via the queue into main with commit c267b43 Apr 24, 2023
@thetaPC
thetaPC deleted the FW-3894 branch April 24, 2023 21:28
<h2>Outside "ion-content"</h2>
<ion-button id="basic-modal">Present modal</ion-button>
<ion-modal trigger="basic-modal">
<h1>Content of doom</h1>

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.

Was the typo intentional @thetaPC? 😄

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.

We've had that verbiage in another test for a while, so it was likely copy and pasted:

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: modal text color is set incorrectly when app and system dark mode settings aren't the same

6 participants