Skip to content

Conversation

@benoitgrelard
Copy link
Contributor

Closes #1235

@benoitgrelard benoitgrelard requested a review from andy-hook as a code owner May 10, 2022 15:59
const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);

React.useEffect(() => {
useLayoutEffect(() => {
Copy link
Contributor Author

@benoitgrelard benoitgrelard May 11, 2022

Choose a reason for hiding this comment

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

Caught another flashing here that I didn't catch before in the React 18 upgrade.

Copy link
Contributor

@andy-hook andy-hook left a comment

Choose a reason for hiding this comment

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

Simple but effective 👌

Should we start adding simple stories to Chromatic for things like this?

@benoitgrelard benoitgrelard merged commit 53053cb into main May 11, 2022
@benoitgrelard benoitgrelard deleted the 1235-select-placeholder branch May 11, 2022 19:16
@benoitgrelard
Copy link
Contributor Author

Should we start adding simple stories to Chromatic for things like this?

We do, I had a story for no value already, and I have added a example with the placeholder to it. So we have both cases.

Let me know if I misunderstood though.

@andy-hook
Copy link
Contributor

Let me know if I misunderstood though.

No you're right, I misread the story location when scanning the diff 👍

@drewkos
Copy link

drewkos commented Jul 6, 2022

@benoitgrelard trying to implement this placeholder value attr, but it's not working for me. is there somethign else I need to do besides add placeholder={placeholderString} to <Select.Value />?

@benoitgrelard
Copy link
Contributor Author

@benoitgrelard trying to implement this placeholder value attr, but it's not working for me. is there somethign else I need to do besides add placeholder={placeholderString} to <Select.Value />?

No that's all, but maybe you are using the latest public rather than the latest release candidate?
This change isn't yet available in the public version.

@MatheusPires99
Copy link

Hey @benoitgrelard , which version exactly the placeholder prop is available?

@benoitgrelard
Copy link
Contributor Author

Hey @MatheusPires99, it's available in latest release candidates. V1 is going out imminently (should be tomorrow).

const context = useSelectContext(VALUE_NAME, __scopeSelect);
const { onValueNodeHasChildrenChange } = context;
const hasChildren = props.children !== undefined;
const hasChildren = children !== undefined;
Copy link

Choose a reason for hiding this comment

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

One of the difficult things for me to figure out was that value has to be undefined for the placeholder to be shown. I used to use null or '' for empty (reset) value, and not just missing. I understand it's a wrong habit to have, just want others to be clear about it.

Choose a reason for hiding this comment

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

This is a veeeery good point, and I just spent 1 hour debugging why my placeholder was not showing up...

luisorbaiceta pushed a commit to luisorbaiceta/primitives that referenced this pull request Jul 21, 2022
* [Select] Add placeholder support

Closes radix-ui#1235

* Update chromatic story

* PR feedback
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.

[Select] Provide a Placeholder component

8 participants