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

[WIP][SelectPanel]: Ensure formbuilder input/defaultvalue is available without opening the selectpanel #3340

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kendallgassner
Copy link
Contributor

Authors: Please fill out this form carefully and completely.

Reviewers: By approving this Pull Request you are approving the code change, as well as its deployment and mitigation plans.
Please read this description carefully. If you feel there is anything unclear or missing, please ask for updates.

What are you trying to accomplish?

Screenshots

Integration

List the issues that this change affects.

Closes # (type the GitHub issue number after #)

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

Anything you want to highlight for special attention from reviewers?

Accessibility

  • Fixes axe scan violation - This change fixes an existing axe scan violation.
  • No new axe scan violation - This change does not introduce any new axe scan violations.
  • New axe violation - This change introduces a new axe scan violation. Please describe why the violation cannot be resolved below.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

Copy link

changeset-bot bot commented Feb 20, 2025

⚠️ No Changeset found

Latest commit: cd24675

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kendallgassner kendallgassner changed the title [WIP]: Setup a preview that uses formBuilder + remote [WIP][SelectPanel]: Ensure formbuilder input/defaultvalue is available without opening the selectpanel Feb 20, 2025
<span data-select-panel-inputs="true">
<%= @form_builder.hidden_field(@input_name, multiple: multi_select?, skip_default_ids: true, value: @default_value) %>
</span>
<% end %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stop using form_builder input in ActionList. This is important since the ActionList input is only available once items are loaded.

Previously, we could only use form_builder with fetch_strategy: :local since the ActionList is loaded on page load using this strategy. This is problematic since most of our usecases are using remote or eventually_local fetch strategies.

Copy link
Contributor

Choose a reason for hiding this comment

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

Stop using form_builder input in ActionList.

ActionMenu also accepts form_arguments and depends on ActionList rendering the hidden form inputs. Would we need to make similar changes in ActionMenu?

There are ~8 instances of ActionMenu with form_arguments and ~3 instances of SelectPanel with form_arguments, so I think we'll need to tread carefully and make sure those existing instances don't break.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. If we're expanding support for form_arguments to non-local strategies, would we also want to account for multi-select and support multiple initial hidden input name/values? (multi-select form example)

  2. Just an observation.. in the EMU select panel instance, the input_name that's passed into the component is overridden with a different name when the action list opens. I was confused by that. The name, input_name is kind of ambiguous and it's not clear to me if it's supposed to be used as the initial hidden input name similar to the default_value you're suggesting here.

# happens in the view that renders the `SelectPanel`, which means the form builder object but isn't available in the
# view that renders the list items. In such a case, it can be useful to create an instance of the form builder maually:
#
# ```erb
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove inaccurate logic.

@@ -375,7 +355,7 @@ def with_avatar_item(**system_arguments)
# @param dynamic_aria_label_prefix [String] If provided, the prefix is prepended to the dynamic label and set as the value of the `aria-label` attribute on the show button.
# @param body_id [String] The unique ID of the panel body. If not provided, the body ID will be set to the panel ID with a "-body" suffix.
# @param list_arguments [Hash] Arguments to pass to the underlying <%= link_to_component(Primer::Alpha::ActionList) %> component. Only has an effect for the local fetch strategy.
# @param form_arguments [Hash] Form arguments to pass to the underlying <%= link_to_component(Primer::Alpha::ActionList) %> component. Only has an effect for the local fetch strategy.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not anymore ✨ !


@form_builder = form_arguments[:builder]
@default_value = form_arguments[:default_value]
@input_name = form_arguments[:name]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extract all form_arguments and add an optional argument default_value so that remote and eventually_local strategies can pass in a pre-set value.

@@ -984,7 +985,7 @@ export class SelectPanelElement extends HTMLElement {

for (const selectedItem of this.selectedItems) {
const newInput = document.createElement('input')
newInput.setAttribute('data-list-input', 'true')
newInput.setAttribute('data-select-panel-input', 'true')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change the search term so we don't accidentally look for ActionList's form_builder input.

# @snapshot interactive
# @param open_on_load toggle
# @param selected_items text
def remote_fetch_form(open_on_load: false, selected_items: "Phaser")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO:
add an exentually_local fetch strategy

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