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

feat: Support multiline inputs for select fields #953

Merged
merged 2 commits into from
Sep 26, 2023

Conversation

bdow
Copy link
Contributor

@bdow bdow commented Sep 25, 2023

SelectField and MultiSelectField will now support multiline inputs either via multiline prop being set to true, or whenever the PresentationProvider.wrap prop is set to true. E.g. When GridTable is rendered with rowHeight: "flexible" (default) then the SelectFields will support wrapping text.

@shortcut-integration
Copy link

@bdow bdow force-pushed the sc-40631/multiline-select branch 4 times, most recently from 1def62f to ba66a91 Compare September 26, 2023 16:00
@bdow bdow force-pushed the sc-40631/multiline-select branch from ba66a91 to a90f42c Compare September 26, 2023 16:24
@bdow bdow marked this pull request as ready for review September 26, 2023 16:27
Copy link
Contributor

@stephenh stephenh left a comment

Choose a reason for hiding this comment

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

Thank you! Really appreciate hoping on this/sneaking it in. 🙏

src/components/Label.tsx Outdated Show resolved Hide resolved
// If we do, we can infer whether we allow wrapping or not based on the PresentationProp. This will currently only be set for "rowHeight: 'fixed'" GridTable styles.
// Or, we can keep our existing default behavior, and allow the user to set `multiline = true` if they want to allow wrapping.
// If we change the default then we could have unexpected text wrapping in places like Filters.
const multilineProps = wrap ? { textAreaMinHeight: 0, multiline: true } : {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Should this multiline: true use the multiline local variable? Not sure...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

multiline should always be true if we ever way the text to wrap. There are two conditions in which we want the text to wrap; 1. The caller defined multiline: true, or 2. PresentationContext.wrap is set to true.
In this case it could be that multiline is undefined, but the PresentationContext property is defined as true, so we'd want to still set multiline: true.

...otherProps
} = props;

const { wrap = multiline } = usePresentationContext();
Copy link
Contributor

Choose a reason for hiding this comment

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

Kinda curious, seems like we have both wrap & multiline now...will they always be aligned, i.e. if wrap=true then multiline=true, and if wrap=false then multiline=false?

Wondering if like multiline=false happens on 73, then they had wrap=true set in PC, we'll end up with wrap=true but multiline=false ... is that okay/a supported configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I glazed over this a bit when doing it so will try to make this a bit simpler / easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alrighty, just went back over it and added a comment above a new variable allowWrap. This variable is going to be true if either ComboboxInputProps.multiline is true, or PresentationContext.wrap is true. i.e.

const allowWrap = wrap || multiline;

For now we'll always expect that if either is set, then we allow it to wrap. Maybe we'll eventually want the local multiline prop to override the presentation provider property if it is explicitly set. But I think for now this is fine.

…comments about ComboBoxInput wrap behavior
@bdow bdow merged commit c2ef18f into main Sep 26, 2023
@bdow bdow deleted the sc-40631/multiline-select branch September 26, 2023 20:09
homebound-team-bot pushed a commit that referenced this pull request Sep 26, 2023
## [2.318.0](v2.317.2...v2.318.0) (2023-09-26)

### Features

* Support multiline inputs for select fields ([#953](#953)) ([c2ef18f](c2ef18f))
@homebound-team-bot
Copy link

🎉 This PR is included in version 2.318.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

...otherProps
} = props;

const { wrap = false } = usePresentationContext();

// Allow the field to wrap whether the caller has explicitly set `multiline=true` or the `PresentationContext.wrap=true`
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants