Sitelet https://web.archive.org/web/20201229125041/https://github.com/mui-org/material-ui/issues/24171
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

[DatePicker] w3c validator issues #24171

Open
annaolchowik opened this issue Aug 13, 2020 · 1 comment
Open

[DatePicker] w3c validator issues #24171

annaolchowik opened this issue Aug 13, 2020 · 1 comment

Comments

@annaolchowik
Copy link

@annaolchowik annaolchowik commented Aug 13, 2020

Hi,
I'm using your Datepicker component.

Is there any chance to fix this?

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

When trying to validate site which uses your Datepicker component I got average about 40 errors, which says:
"Element “p” not allowed as child of element “span” in this context. (Suppressing further errors from this subtree.)"

Expected Behavior 🤔

element p should not be inside inline span block.

Steps to Reproduce 🕹

Please see Link to your Datepicker component demo site below:
https://next.material-ui.com/components/date-picker/

Your Environment 🌎

Tech Version
Material-UI v4.9.8
Material-UI/pickers v3.2.10
React 16.11.0
Browser Chrome Version 84.0.4147.105
TypeScript 3.6.4
@oliviertassinari oliviertassinari transferred this issue from mui-org/material-ui Aug 13, 2020
@oliviertassinari oliviertassinari changed the title w3c validator return Element p not allowed as child of element span in this context. [DatePicker] w3c validator issues Dec 29, 2020
@oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Dec 29, 2020

@annaolchowik Thanks for the report. While the issue you have reported seems to be fixed, we have a different one now:

Capture d’écran 2020-12-29 à 13 31 09

What do you think about the following fix, do you want to work on a pull request :)?

diff --git a/packages/material-ui-lab/src/DateRangePickerDay/DateRangePickerDay.tsx b/packages/material-ui-lab/src/DateRangePickerDay/DateRangePickerDay.tsx
index 19351c3970..a96aeb2005 100644
--- a/packages/material-ui-lab/src/DateRangePickerDay/DateRangePickerDay.tsx
+++ b/packages/material-ui-lab/src/DateRangePickerDay/DateRangePickerDay.tsx
@@ -125,6 +125,7 @@ const DateRangePickerDay = React.forwardRef(function DateRangePickerDay<TDate>(

   return (
     <div
+      role="cell"
       data-mui-test={shouldRenderHighlight ? 'DateRangeHighlight' : undefined}
       className={clsx(classes.root, className, {
         [classes.rangeIntervalDayHighlight]: shouldRenderHighlight,
diff --git a/packages/material-ui-lab/src/DayPicker/PickersCalendar.tsx b/packages/material-ui-lab/src/DayPicker/PickersCalendar.tsx
index 1912d722e7..41ccbb6793 100644
--- a/packages/material-ui-lab/src/DayPicker/PickersCalendar.tsx
+++ b/packages/material-ui-lab/src/DayPicker/PickersCalendar.tsx
@@ -193,7 +193,6 @@ function PickersCalendar<TDate>(props: PickersCalendarProps<TDate> & WithStyles<
                   const dayProps: PickersDayProps<TDate> = {
                     key: (day as any)?.toString(),
                     day,
-                    role: 'cell',
                     isAnimating: isMonthSwitchingAnimating,
                     disabled: isDateDisabled(day),
                     allowKeyboardControl,
@@ -220,7 +219,9 @@ function PickersCalendar<TDate>(props: PickersCalendarProps<TDate> & WithStyles<
                   return renderDay ? (
                     renderDay(day, selectedDates, dayProps)
                   ) : (
-                    <PickersDay {...dayProps} />
+                    <div role="cell">
+                      <PickersDay {...dayProps} />
+                    </div>
                   );
                 })}
               </div>

The solution is based on https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/datepicker-dialog.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.