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

Allow address fields to be disabled #974

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jagthedrummer
Copy link
Contributor

@jagthedrummer jagthedrummer commented Nov 26, 2024

This allows you to pass options: {disabled: true} to disable the entire address field.

Like this:

<%= render 'shared/fields/address_field', method: :address_value, options: {disabled: true} %>

It disabled every input that's a part of the address, regardless of whether the address has been populated previously.

Empty initial state:

CleanShot 2024-11-26 at 10 24 13

With a previously populated address:

CleanShot 2024-11-26 at 10 24 44

This finally fixes #573

.select2-container--default.select2-container--disabled .select2-selection--multiple{
@apply bg-slate-200 dark:bg-slate-700 hover:bg-slate-200 hover:dark:bg-slate-700
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes it so that disabled super selects have the same background colors as other disabled inputs. Without this disabling the address looks like this:

CleanShot 2024-11-26 at 10 46 41

postal_code_options ||= {}
postal_code_options[:data] ||= {}
region_html_options ||= {}
region_html_options[:data] ||= {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to create separate options hashes for each individual input because if we pass the same hash to each input they all end up with the same id on the actual input elements. The duplicate id thing happens because of this line:

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.

Disabled field partials should indicate that they're disabled
1 participant