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(DatePicker/CalendarMonth): better range styling when some dates are disabled #10398

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

adamviktora
Copy link
Contributor

@adamviktora adamviktora commented May 21, 2024

Closes #9933

  • shows styling on a range even if some of the dates of the range (including rangeStart) may be disabled with the validators prop
  • tries to autofocus the dateProp first (rangeEnd) over rangeStart. If no dateProp is given, tries to autofocus the rangeStart over today

Related to discussion on the working session - I decided not to attempt to find a closest focusable date, neither to add the prop to customize which month should be open. It might be useful only in rare use case like having a validator that disables large amount of dates (and it could complicate things more than be useful). - but let me know if it is something we might want to add

@patternfly-build
Copy link
Contributor

patternfly-build commented May 21, 2024

const focusSelectorForUnselectedDate = createFocusSelectorString(calendarMonthStyles.modifiers.current);

const getElementToFocus = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment here to just explain the purpose of this function? I think this all looks good but I'm also finding the complexity of all this stuff pretty hard to follow 😂

@@ -412,8 +412,8 @@ export const CalendarMonth = ({
isAdjacentMonth && styles.modifiers.adjacentMonth,
isToday && styles.modifiers.current,
(isSelected || isRangeStart) && styles.modifiers.selected,
!isValid && styles.modifiers.disabled,
(isInRange || isRangeStart || isRangeEnd) && styles.modifiers.inRange,
!isValid && !(isInRange || isRangeStart || isRangeEnd || isSelected) && styles.modifiers.disabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to apply this same logic elsewhere where we're applying disabled styling/setting disabled prop. Using the validator from the issue (date > from rather than date >= from), the rangeStart date for the second datepicker doesn't have the expected styling:

image

Copy link
Contributor Author

@adamviktora adamviktora May 28, 2024

Choose a reason for hiding this comment

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

I think this is due to the docs building error resolved in #10416, it looks fine locally.
EDIT: I rebased and the example looks good now

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Latest build looks good when using the validator mentioned in the issue

@nicolethoen nicolethoen merged commit b8710bc into patternfly:main Jun 3, 2024
13 checks passed
tlabaj pushed a commit to tlabaj/patternfly-react that referenced this pull request Jun 17, 2024
…re disabled (patternfly#10398)

* fix(DatePicker/CalendarMonth): range styling when disabled dates

* chore(Datepicker): getElementSelectorToFocus function description
tlabaj pushed a commit to tlabaj/patternfly-react that referenced this pull request Jun 17, 2024
…re disabled (patternfly#10398)

* fix(DatePicker/CalendarMonth): range styling when disabled dates

* chore(Datepicker): getElementSelectorToFocus function description
tlabaj pushed a commit to tlabaj/patternfly-react that referenced this pull request Jun 24, 2024
…re disabled (patternfly#10398)

* fix(DatePicker/CalendarMonth): range styling when disabled dates

* chore(Datepicker): getElementSelectorToFocus function description
tlabaj pushed a commit to tlabaj/patternfly-react that referenced this pull request Jun 25, 2024
…re disabled (patternfly#10398)

* fix(DatePicker/CalendarMonth): range styling when disabled dates

* chore(Datepicker): getElementSelectorToFocus function description
gitdallas pushed a commit that referenced this pull request Jun 25, 2024
* docs(Page): add example showing different type prop variants (#10352)

* docs(Page): add example showing different type prop variants

* docs(Page): make text color white in "subnav" section

* docs(Page): rename IDs in example

* docs(Table): update column management example to use link button for Cancel action (#10459)

* feat(Modal): support ReactNode type for 'title' prop

* fix(DatePicker/CalendarMonth): better range styling when some dates are disabled (#10398)

* fix(DatePicker/CalendarMonth): range styling when disabled dates

* chore(Datepicker): getElementSelectorToFocus function description

* feat(MenuToggle): add OUIA support

* docs(menu-toggle): Adds docs for split button examples. (#10268)

* docs(menu-toggle): Adds docs for split button examples.

* Update names of split toggle examples.

* Add description list basic demo (#10184)

* add description list basic demo

* fix DashboardWrapper not found issue

* implement review comments

* add divider and size

* update content

* fixed layout issues

* Convert demo application to Vite

* Upgrade Testing Library dependencies to latest version

* upgrade  to latest version

* upgrade  to latest version

* upgrade  to latest version

* chore(deps): replace camel-case with change-case

* Masthead: add demo that includes horizontal nav

* chore: use  protocol for workspace dependencies

* chore(deps): upgrade  to the latest version

* chore(deps): upgrade  to the latest version

* chore(deps): upgrade  to the latest version

* chore(deps): remove unused  dependency

* chore(deps): upgrade  to the latest version

* chore(deps): ugprade Jest to latest version

* chore(deps): upgrade  to the latest version

* chore(deps): upgrade  dependencies to the latest version

* chore(deps): upgrade  to the latest version

* chore(deps): update dependencies

* update yarn file

* more deps fixes

* more deps

* fix(build): get our custom TS transformers working again (#10477)

* fix(build): get our custom TS transformers working again

* chore(deps): Update lock file

* Update lock file

* chore(deps): Update yarn lock

* fix demo app

* cherry pick yarn changes

* update yarn.lock

* updatw snapshots

* fix demo app

* feat(templates): toggle props & improvements (#10473)

* feat(templates): toggle props & improvements

* remove toggleContent from typeahead template

* update template names

* update tests

* added SimpleSelect tests

* fix yarnlock

* fix(CodeEditor) support Mac and PC shortcuts in example (#10472)

* updatee lock file

---------

Co-authored-by: adamviktora <84135613+adamviktora@users.noreply.github.com>
Co-authored-by: Erin Donehoo <105813956+edonehoo@users.noreply.github.com>
Co-authored-by: Ajay Pratap <ajay.pratap233@gmail.com>
Co-authored-by: Austin Sullivan <ausulliv@redhat.com>
Co-authored-by: kmcfaul <45077788+kmcfaul@users.noreply.github.com>
Co-authored-by: Dominik Petřík <77832970+Dominik-Petrik@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug - Datepicker - End date validator lacks support for "isSameOrBefore" case
4 participants