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: Allow text selection in date picker and date range picker #3181

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/date-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ const DatePicker = React.forwardRef(

baseProps.className = clsx(baseProps.className, styles.root, styles['date-picker-container']);

const handleMouseDown = (event: React.MouseEvent) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This was preventing text selection in date picker even after removing user-select: none from the dropdown.

It was introduced 3.5 years ago in CR-49510605 with the justification to prevent an undesired focus ring from appearing when clicking the calendar, but I can't reproduce this today.

// prevent currently focused element from losing it
event.preventDefault();
};

return (
<div {...baseProps} ref={mergedRef} onKeyDown={!disabled && !readOnly ? onWrapperKeyDownHandler : undefined}>
{disabled || readOnly ? (
Expand All @@ -183,7 +178,6 @@ const DatePicker = React.forwardRef(
stretchHeight={true}
open={isDropDownOpen}
onDropdownClose={onDropdownCloseHandler}
onMouseDown={handleMouseDown}
trigger={trigger}
expandToViewport={expandToViewport}
scrollable={false}
Expand Down
2 changes: 0 additions & 2 deletions src/date-range-picker/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ $calendar-header-color: awsui.$color-text-body-default;
}

.label {
user-select: text;
Copy link
Member Author

Choose a reason for hiding this comment

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

These two rules to override the parent's behavior are not necessary anymore

cursor: default;
}

Expand Down Expand Up @@ -173,7 +172,6 @@ $calendar-header-color: awsui.$color-text-body-default;
}

.dropdown-content {
user-select: text;
background-color: awsui.$color-background-container-content;
inline-size: calc(2 * #{$calendar-grid-width} + #{awsui.$space-xs} + 2 * #{awsui.$space-l});

Expand Down
1 change: 0 additions & 1 deletion src/internal/components/dropdown/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
display: none;
// Needs to be higher than a global navigation element
z-index: 2000;
user-select: none;
transform-origin: top;

// When used in portal we need z-index to be higher than modal's
Expand Down
1 change: 1 addition & 0 deletions src/internal/components/options-list/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
border-start-end-radius: awsui.$border-radius-dropdown;
border-end-start-radius: awsui.$border-radius-dropdown;
border-end-end-radius: awsui.$border-radius-dropdown;
user-select: none;

&-embedded {
border-start-start-radius: 0px;
Expand Down
Loading