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: Apply width styles to titleField in table layout #69191

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

SainathPoojary
Copy link
Contributor

@SainathPoojary SainathPoojary commented Feb 13, 2025

Closes: #69185

What?

Apply layout styles (width, maxWidth, minWidth) to the primary column (titleField) in DataViews table layout, consistent with how they are applied to other fields.

Why?

Currently, width-related styles from view.layout.styles are only applied to regular fields but not to the primary column (titleField). This inconsistency prevents consumers from controlling table layout shifts through min/max widths for all columns, including the primary column.

How?

Added style properties to both the table header () and table cell () elements for the primary column, applying the same width-related styles that are already supported for other fields:

  • width
  • maxWidth
  • minWidth

The styles are conditionally applied based on the existence of the titleField and its corresponding styles in the view.layout configuration.

Testing Instructions

  1. Start the Storybook development server: npm run storybook:dev
  2. Navigate to "DataViews > DataViews > Default" story
  3. Modify the default view configuration to include width styles for both title and categories:
const [view, setView] = useState<View>({
  ...DEFAULT_VIEW,
  fields: ['categories'],
  titleField: 'title',
  descriptionField: 'description',
  mediaField: 'image',
  layout: {
    styles: {
      title: {
        maxWidth: '200px',
      },
      categories: {
        maxWidth: '200px',
      },
    },
  },
});
  1. Inspect the DataViews table in the browser
  2. Verify that both the title and categories columns have the maxWidth style applied to their respective cells

Screenshots

Before After
image image

@SainathPoojary SainathPoojary marked this pull request as ready for review February 14, 2025 06:55
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: SainathPoojary <[email protected]>
Co-authored-by: nani-samireddy <[email protected]>
Co-authored-by: oandregal <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] DataViews /packages/dataviews labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] DataViews /packages/dataviews [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataViews: layout styles are not applied to titleField column
2 participants