Skip to content

Commit 3af68b6

Browse files
fix: avoid readonly attribute on select element (ietf-tools#4819)
* fix: avoid readonly attribute on select element * chore: remove now-unused CSS for select2 * test: don't ignore `readonly` on `select` * refactor: simplify OutgoingLiaisonForm base class overrides
1 parent 9457e2b commit 3af68b6

3 files changed

Lines changed: 4 additions & 21 deletions

File tree

ietf/liaisons/forms.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,6 @@ def set_to_fields(self):
471471

472472

473473
class OutgoingLiaisonForm(LiaisonModelForm):
474-
from_contact = SearchableEmailField(only_users=True)
475474
approved = forms.BooleanField(label="Obtained prior approval", required=False)
476475

477476
class Meta:
@@ -501,6 +500,7 @@ def set_from_fields(self):
501500
self.fields['from_groups'].initial = [flat_choices[0][0]]
502501

503502
if has_role(self.user, "Secretariat"):
503+
self.fields['from_contact'] = SearchableEmailField(only_users=True) # secretariat can edit this field!
504504
return
505505

506506
if self.person.role_set.filter(name='liaiman',group__state='active'):
@@ -509,8 +509,10 @@ def set_from_fields(self):
509509
email = self.person.role_set.filter(name__in=('ad','chair'),group__state='active').first().email.address
510510
else:
511511
email = self.person.email_address()
512+
513+
# Non-secretariat user cannot change the from_contact field. Fill in its value.
514+
self.fields['from_contact'].disabled = True
512515
self.fields['from_contact'].initial = email
513-
self.fields['from_contact'].widget.attrs['readonly'] = True
514516

515517
def set_to_fields(self):
516518
'''Set to_groups and to_contacts options and initial value based on user

ietf/static/css/select2.scss

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,3 @@
33
@import "bootstrap/scss/mixins";
44
@import "select2/src/scss/core";
55
@import "select2-bootstrap-5-theme/src/include-all";
6-
7-
// Propagate readonly property from input to select2 instrumentation, based on
8-
// https://stackoverflow.com/questions/41807096/select2-make-it-readonly-not-disabled-from-js/55001516#55001516
9-
select[readonly].select2-hidden-accessible + .select2-container {
10-
pointer-events: none;
11-
touch-action: none;
12-
13-
.select2-selection {
14-
background: $form-select-disabled-bg;
15-
color: $form-select-disabled-color;
16-
border-color: $form-select-disabled-border-color;
17-
box-shadow: none;
18-
}
19-
20-
.select2-selection__arrow, .select2-selection__clear {
21-
display: none;
22-
}
23-
}

ietf/utils/test_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ def vnu_filter_message(msg, filter_db_issues, filter_test_issues):
203203

204204
return re.search(
205205
r"""document\ is\ not\ mappable\ to\ XML\ 1|
206-
Attribute\ 'readonly'\ not\ allowed\ on\ element\ 'select'|
207206
^Attribute\ 'required'\ not\ allowed\ on\ element\ 'div'|
208207
^The\ 'type'\ attribute\ is\ unnecessary\ for\ JavaScript|
209208
is\ not\ in\ Unicode\ Normalization\ Form\ C""",

0 commit comments

Comments
 (0)