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

DataViews: update names for DropdownMenuRadioItemCustom #57416

Merged
merged 1 commit into from
Dec 28, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/dataviews/src/add-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function AddFilter( { filters, view, onChangeView } ) {
return (
<DropdownMenuRadioItemCustom
key={ element.value }
name={ `add-filter-${ filter.field.id }` }
name={ `add-filter-${ filter.field }` }
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 rendered add-filter-undefined and now it renders add-filter-author (for the author filter).

value={ element.value }
checked={ isActive }
onClick={ () => {
Expand Down Expand Up @@ -172,7 +172,7 @@ export default function AddFilter( { filters, view, onChangeView } ) {
] ) => (
<DropdownMenuRadioItem
key={ key }
name={ `add-filter-${ filter.name }-conditions` }
name={ `add-filter-${ filter.field }-conditions` }
Copy link
Member Author

@oandregal oandregal Dec 28, 2023

Choose a reason for hiding this comment

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

This rendered add-filter-Author-conditions and now it renders add-filter-author-conditions. Note that fields could have names such as Author Name, so I thought it best to use the id.

value={ operator }
checked={
activeOperator ===
Expand Down
5 changes: 4 additions & 1 deletion packages/dataviews/src/dropdown-menu-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const radioCheck = (
* component, which allows deselecting selected values.
*/
export const DropdownMenuRadioItemCustom = forwardRef(
( { checked, name, value, onChange, onClick, ...props }, ref ) => {
function DropdownMenuRadioItemCustom(
Copy link
Member Author

Choose a reason for hiding this comment

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

React devtools will show DropdownMenuRadioItemCustom if we pass a named function to forwardRef.

{ checked, name, value, onChange, onClick, ...props },
ref
) {
const onClickHandler = ( e ) => {
onClick?.( e );
onChange?.( { ...e, target: { ...e.target, value } } );
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/src/filter-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function FilterSummary( { filter, view, onChangeView } ) {
return (
<DropdownMenuRadioItemCustom
key={ element.value }
name={ `filter-summary-${ filter.field.id }` }
name={ `filter-summary-${ filter.field }` }
value={ element.value }
checked={ isActive }
onClick={ () =>
Expand Down Expand Up @@ -150,7 +150,7 @@ export default function FilterSummary( { filter, view, onChangeView } ) {
( [ operator, { label, key } ] ) => (
<DropdownMenuRadioItemCustom
key={ key }
name={ `filter-summary-${ filter.name }-conditions` }
name={ `filter-summary-${ filter.field }-conditions` }
value={ operator }
checked={ activeOperator === operator }
onChange={ ( e ) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/src/view-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function HeaderMenu( { field, view, onChangeView } ) {
return (
<DropdownMenuRadioItemCustom
key={ element.value }
name={ `view-table-${ filter.field.id }` }
name={ `view-table-${ filter.field }` }
value={ element.value }
checked={ isActive }
onClick={ () => {
Expand Down Expand Up @@ -222,7 +222,7 @@ function HeaderMenu( { field, view, onChangeView } ) {
] ) => (
<DropdownMenuRadioItemCustom
key={ key }
name={ `view-table-${ filter.name }-conditions` }
name={ `view-table-${ filter.field }-conditions` }
value={ operator }
checked={
activeOperator ===
Expand Down