fix: revert change from readonly to disabled on liaison from contact (#4708)

* feat: apply 'readonly' property to select2 inputs

* fix: revert change from readonly to disabled on liaison from contact
This commit is contained in:
Jennifer Richards 2022-11-06 08:27:36 -04:00 committed by GitHub
parent d7f5c20a28
commit 331bf8d2dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -510,7 +510,7 @@ class OutgoingLiaisonForm(LiaisonModelForm):
else:
email = self.person.email_address()
self.fields['from_contact'].initial = email
self.fields['from_contact'].widget.attrs['disabled'] = True
self.fields['from_contact'].widget.attrs['readonly'] = True
def set_to_fields(self):
'''Set to_groups and to_contacts options and initial value based on user

View file

@ -3,3 +3,21 @@
@import "bootstrap/scss/mixins";
@import "select2/src/scss/core";
@import "select2-bootstrap-5-theme/src/include-all";
// Propagate readonly property from input to select2 instrumentation, based on
// https://stackoverflow.com/questions/41807096/select2-make-it-readonly-not-disabled-from-js/55001516#55001516
select[readonly].select2-hidden-accessible + .select2-container {
pointer-events: none;
touch-action: none;
.select2-selection {
background: $form-select-disabled-bg;
color: $form-select-disabled-color;
border-color: $form-select-disabled-border-color;
box-shadow: none;
}
.select2-selection__arrow, .select2-selection__clear {
display: none;
}
}