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

Broken react select styling for large values #4812

Merged

Conversation

robinmolen
Copy link
Contributor

Closes #4802

Changes

  • Fixing the bug by ensuring that the .admin-react-select element can't grow beyond its max-inline-size
  • Replaced the DocumentTypes and CaseTypeSelect select option html labels with simple text labels. The html labels are now added as a custom Option component for the ReactSelect. This means that the html labels will only be used when the option is presented in the dropdown, otherwise the simple text label will be used.
  • Updated the storybook mock data to showcase large option labels for DocumentTypes and CaseTypeSelect

Checklist

Check off the items that are completed or not relevant.

  • Impact on features

    • Checked copying a form
    • Checked import/export of a form
    • Config checks in the configuration overview admin page
    • Problem detection in the admin email digest is handled
  • Release management

    • I have labelled the PR as "needs-backport" accordingly
  • I have updated the translations assets (you do NOT need to provide translations)

    • Ran ./bin/makemessages_js.sh
    • Ran ./bin/compilemessages_js.sh
  • Commit hygiene

    • Commit messages refer to the relevant Github issue
    • Commit messages explain the "why" of change, not the how

@robinmolen robinmolen requested a review from stevenbal November 6, 2024 10:23
@robinmolen robinmolen linked an issue Nov 6, 2024 that may be closed by this pull request
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.55%. Comparing base (22d641b) to head (0db34e9).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4812   +/-   ##
=======================================
  Coverage   96.55%   96.55%           
=======================================
  Files         748      748           
  Lines       25413    25413           
  Branches     3358     3358           
=======================================
  Hits        24538    24538           
  Misses        610      610           
  Partials      265      265           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1,8 +1,9 @@
import classNames from 'classnames';
import {useField, useFormikContext} from 'formik';
import PropTypes from 'prop-types';
import {useContext, useEffect} from 'react';
import React, {useContext, useEffect} from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

we use the automatic jsx runtime, so the React import is not necessary :) (it's also not wrong)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah okay, check. I'm also not sure why this was added... 😅
But i'll remove it :)

Comment on lines 44 to 48
return documentTypes.map(({omschrijving}) => ({
value: omschrijving,
label: (
label: omschrijving,
}));
Copy link
Member

Choose a reason for hiding this comment

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

isn't isPublished missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh shit, your right..

@@ -25,4 +25,5 @@
100%,
var(--of-admin-select-max-inline-size)
);
max-inline-size: var(--of-admin-select-max-inline-size);
Copy link
Member

Choose a reason for hiding this comment

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

I've had to do this in more places in other projects and now I no longer understand how clamp works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i also dont fully understand why the max-inline-size was needed.. Maybe because a child element was growing, instead of the .admin-react-select. So that the max-inline-size prevent all growth?

I think the clamp just allows the parent to grow between a min and max value, but it doesn't work fully for flexbox child elements? That they don't respect the set value, and grow beyond? The .admin-react-select is used in a flex-wrap environment, which might also complicate things..

But I haven't checked/investigated it so deeply..

The .catalogi-type-option span element is only needed for the dropdown menu, not when it is the selected value. So the element should only be added when it's used in the dropdown menu.
This also solves some styling issues when the content is beyond the max size of the ReactSelect
@robinmolen robinmolen force-pushed the bug/4802-react-select-styling-for-large-values branch from cd38d52 to 0db34e9 Compare November 7, 2024 10:19
@sergei-maertens sergei-maertens merged commit 7a6e0d3 into master Nov 7, 2024
33 of 34 checks passed
@sergei-maertens sergei-maertens deleted the bug/4802-react-select-styling-for-large-values branch November 7, 2024 10:53
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.

React select styling issue with large values
2 participants