Skip to content

Conversation

benjaminleonard
Copy link
Contributor

Attach disk has only one item, would work better as a regular modal. This does that and adds a complementary ModalForm component to match the SideModalForm.

Copy link

vercel bot commented Mar 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Apr 16, 2025 4:22pm

@david-crespo
Copy link
Collaborator

Nice. Would like to see at least one existing one converted to see how much fiddliness we're saving. Don't necessarily need to convert them all, but it's probably not too hard.

* calling code. We could do that internally with `cloneElement` instead, but
* then in the calling code, the field would not infer `TFieldValues` and
* constrain the `name` prop to paths in the values object.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

variant="info"
content="Once an image has been promoted it is visible to all projects in a silo"
/>
</ModalForm>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is pretty satisfying. Feels a lot harder to mess up.

@david-crespo
Copy link
Collaborator

david-crespo commented Mar 5, 2025

One thing to keep an eye out for is that there is at least one of these modal forms that isn't supposed to have a <form> element at all because it's inside another form. I see the stopPropagation thing inside onSubmit is supposed to fix that (nice comment, past me), so maybe we're good, and the problem when I tried it came from using the <form> directly without stopPropagation.

Strictly speaking, form inside form is Not Allowed, but it's entirely possible it's fine as long as we mitigate this particular issue.

Edit: I think the above is true, but ONLY because we are rendering the form in a modal in a portal, which means from the DOM's point of view it is not actually nested. The stopPropagation is still needed to prevent events from bubbling up through the portal, which they can do for some reason.

image

@david-crespo
Copy link
Collaborator

david-crespo commented Mar 5, 2025

Disk attach is opening with its tongue out on both instance create and instance disks tab. Can't have that.

2025-03-05-model-tongue-out.mp4
image

@benjaminleonard
Copy link
Contributor Author

Edit: I think the above is true, but ONLY we are rendering the form in a modal in a portal, which means from the DOM's point of view it is not actually nested. The stopPropagation is still needed to prevent events from bubbling up through the portal, which they can do for some reason.

Yeah I tried without stopPropagation initially, and the attach disk modal would submit the entire form – so definitely still necessary here too.

Disk attach is opening with its tongue out on both instance create and instance disks tab. Can't have that.

Hmm, it does on the side pane also but less obvious because its not sticking out. Since it automatically focuses the first input and focusing options the listbox. Not sure what the solution is here? Perhaps it shouldn't be opening on focus, and instead if the user presses a key when its focused (or clicks ofc). Should explore this further.

<ModalForm
form={form}
onDismiss={onDismiss}
submitLabel="Attach floating IP"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to think about our approach to labels here? As in do we use the full version as it is, or just use the verb for. Aka "attach", "create", "save"

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think just the verb, otherwise it's too long.

Copy link
Collaborator

@david-crespo david-crespo Apr 9, 2025

Choose a reason for hiding this comment

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

On second thought I like the nouns. I'll try this as Attach IP to make it shorter.

</form>
</Modal.Section>
</Modal.Body>
<Modal.Footer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the SideModelForm and FullPageForm we let the user pass in the buttons directly. This way is more foolproof, but maybe worth considering unifying our approach.

@david-crespo david-crespo changed the title Attach disk modal Attach disk modal + ModalForm Apr 9, 2025
@david-crespo david-crespo marked this pull request as ready for review April 9, 2025 20:41
@david-crespo
Copy link
Collaborator

This all looks good, I'm about ready to merge. I was playing around with the modal opening with the combobox focused, and I found that by moving the close button back to being the first thing, we don't have the problem, and I don't see the distracting focus ring on the close button (which I vaguely remember was the main reason we didn't want it focusing by default). Seems ok?

image

@benjaminleonard
Copy link
Contributor Author

This would be a departure from the side modal – and I think it's generally helpful to hit the first input on open. Might be worth prodding at the listbox to see if there's a way we can require input or the user to press enter to open?

@benjaminleonard
Copy link
Contributor Author

Thinking of this behaviour:

https://headlessui.com/react/combobox

@david-crespo
Copy link
Collaborator

Oh, very good point. So we are using the immediate prop, which causes this behavior.

https://headlessui.com/react/combobox#opening-the-dropdown-on-focus

<HCombobox
// necessary, as the displayed "value" is not the same as the actual selected item's *value*
value={selectedItemValue}
// fallback to '' allows clearing field to work
onChange={(val) => onChange(val || '')}
// we only want to keep the query on close when arbitrary values are allowed
onClose={allowArbitraryValues ? undefined : () => setQuery('')}
disabled={disabled || isLoading}
immediate
{...props}
>

Turning it off produces the below behavior. The options don't show on focus — they only show up when you either type something or click the button. Not sure how I feel about it. I might just be used to the current behavior. It probably says something that immediate=false is the default.

2025-04-18-listbox-non-immediate.mp4

@david-crespo
Copy link
Collaborator

Yeah, it feels kinda sad to me to click on a combobox and not see the things listed, and it doesn't feel very intuitive that you have to start typing when you might not know what you're looking for. Clicking the button doesn't feel that intuitive either. Between that and the things being open by default, I think I would choose the latter. You should try it — all you have to do is comment out immediate in Combobox.tsx.

@david-crespo david-crespo merged commit 5c7c8b5 into main Apr 18, 2025
7 checks passed
@david-crespo david-crespo deleted the attach-disk-modal branch April 18, 2025 21:00
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request May 7, 2025
oxidecomputer/console@99a1f00...46e244f

* [46e244fd](oxidecomputer/console@46e244fd) oxidecomputer/console#2818
* [9811a9c7](oxidecomputer/console@9811a9c7) element=null on root redirect route to silence warnings
* [b8e9f385](oxidecomputer/console@b8e9f385) oxidecomputer/console#2821
* [f097ec96](oxidecomputer/console@f097ec96) oxidecomputer/console#2819
* [585fe913](oxidecomputer/console@585fe913) oxidecomputer/console#2815
* [973d332a](oxidecomputer/console@973d332a) oxidecomputer/console#2817
* [ad61a081](oxidecomputer/console@ad61a081) oxidecomputer/console#2816
* [239e34b9](oxidecomputer/console@239e34b9) oxidecomputer/console#2806
* [376f172f](oxidecomputer/console@376f172f) oxidecomputer/console#2805
* [5c7c8b5b](oxidecomputer/console@5c7c8b5b) oxidecomputer/console#2746
* [1d8c3b76](oxidecomputer/console@1d8c3b76) bump playwright, use more cores to run e2es locally
* [f493cb35](oxidecomputer/console@f493cb35) oxidecomputer/console#2772
* [819b99a6](oxidecomputer/console@819b99a6) chore: type error after RR 7.5. this is why we make PRs
* [c1134cff](oxidecomputer/console@c1134cff) chore: react-router 7.5.0
* [c1f0d78b](oxidecomputer/console@c1f0d78b) chore: vite 6.3.0 + vitest 3.1.1
* [79c6bc53](oxidecomputer/console@79c6bc53) oxidecomputer/console#2803
* [f454f5ee](oxidecomputer/console@f454f5ee) oxidecomputer/console#2804
* [ccfa5a58](oxidecomputer/console@ccfa5a58) fix deploy-dogfood script when used with a tag
* [6196fa48](oxidecomputer/console@6196fa48) invalidate anti-affinity group member lists on instance action success
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request May 7, 2025
oxidecomputer/console@99a1f00...46e244f

* [46e244fd](oxidecomputer/console@46e244fd)
oxidecomputer/console#2818
* [9811a9c7](oxidecomputer/console@9811a9c7)
element=null on root redirect route to silence warnings
* [b8e9f385](oxidecomputer/console@b8e9f385)
oxidecomputer/console#2821
* [f097ec96](oxidecomputer/console@f097ec96)
oxidecomputer/console#2819
* [585fe913](oxidecomputer/console@585fe913)
oxidecomputer/console#2815
* [973d332a](oxidecomputer/console@973d332a)
oxidecomputer/console#2817
* [ad61a081](oxidecomputer/console@ad61a081)
oxidecomputer/console#2816
* [239e34b9](oxidecomputer/console@239e34b9)
oxidecomputer/console#2806
* [376f172f](oxidecomputer/console@376f172f)
oxidecomputer/console#2805
* [5c7c8b5b](oxidecomputer/console@5c7c8b5b)
oxidecomputer/console#2746
* [1d8c3b76](oxidecomputer/console@1d8c3b76)
bump playwright, use more cores to run e2es locally
* [f493cb35](oxidecomputer/console@f493cb35)
oxidecomputer/console#2772
* [819b99a6](oxidecomputer/console@819b99a6)
chore: type error after RR 7.5. this is why we make PRs
* [c1134cff](oxidecomputer/console@c1134cff)
chore: react-router 7.5.0
* [c1f0d78b](oxidecomputer/console@c1f0d78b)
chore: vite 6.3.0 + vitest 3.1.1
* [79c6bc53](oxidecomputer/console@79c6bc53)
oxidecomputer/console#2803
* [f454f5ee](oxidecomputer/console@f454f5ee)
oxidecomputer/console#2804
* [ccfa5a58](oxidecomputer/console@ccfa5a58)
fix deploy-dogfood script when used with a tag
* [6196fa48](oxidecomputer/console@6196fa48)
invalidate anti-affinity group member lists on instance action success
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.

2 participants