mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-13 21:49:26 +02:00
Improve bookmark form accessibility (#1116)
* Bump Django * Render error messages in English * Remove unused USE_L10N option * Associate errors and help texts with form fields * Make checkbox inputs clickable * Change cancel button text * Fix tests
This commit is contained in:
@@ -78,9 +78,9 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
html = response.content.decode()
|
||||
|
||||
self.assertInHTML(
|
||||
'<input type="text" name="url" value="http://example.com" '
|
||||
'placeholder=" " autofocus class="form-input" required '
|
||||
'id="id_url">',
|
||||
"""
|
||||
<input type="text" name="url" aria-invalid="false" autofocus class="form-input" required id="id_url" value="http://example.com">
|
||||
""",
|
||||
html,
|
||||
)
|
||||
|
||||
@@ -117,9 +117,10 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
html = response.content.decode()
|
||||
|
||||
self.assertInHTML(
|
||||
'<input type="text" name="tag_string" value="tag1 tag2 tag3" '
|
||||
'class="form-input" autocomplete="off" autocapitalize="off" '
|
||||
'id="id_tag_string">',
|
||||
"""
|
||||
<input type="text" name="tag_string" value="tag1 tag2 tag3"
|
||||
aria-describedby="id_tag_string_help" autocapitalize="off" autocomplete="off" class="form-input" id="id_tag_string">
|
||||
""",
|
||||
html,
|
||||
)
|
||||
|
||||
@@ -137,8 +138,8 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
<span class="form-label d-inline-block">Notes</span>
|
||||
</summary>
|
||||
<label for="id_notes" class="text-assistive">Notes</label>
|
||||
<textarea name="notes" cols="40" rows="8" class="form-input" id="id_notes">**Find** more info [here](http://example.com)</textarea>
|
||||
<div class="form-input-hint">
|
||||
<textarea name="notes" cols="40" rows="8" class="form-input" id="id_notes" aria-describedby="id_notes_help">**Find** more info [here](http://example.com)</textarea>
|
||||
<div id="id_notes_help" class="form-input-hint">
|
||||
Additional notes, supports Markdown.
|
||||
</div>
|
||||
</details>
|
||||
@@ -196,12 +197,12 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
|
||||
self.assertInHTML(
|
||||
"""
|
||||
<label for="id_shared" class="form-checkbox">
|
||||
<input type="checkbox" name="shared" id="id_shared">
|
||||
<i class="form-icon"></i>
|
||||
<span>Share</span>
|
||||
</label>
|
||||
""",
|
||||
<div class="form-checkbox">
|
||||
<input type="checkbox" name="shared" aria-describedby="id_shared_help" id="id_shared">
|
||||
<i class="form-icon"></i>
|
||||
<label for="id_shared">Share</label>
|
||||
</div>
|
||||
""",
|
||||
html,
|
||||
count=0,
|
||||
)
|
||||
@@ -213,12 +214,12 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
|
||||
self.assertInHTML(
|
||||
"""
|
||||
<label for="id_shared" class="form-checkbox">
|
||||
<input type="checkbox" name="shared" id="id_shared">
|
||||
<i class="form-icon"></i>
|
||||
<span>Share</span>
|
||||
</label>
|
||||
""",
|
||||
<div class="form-checkbox">
|
||||
<input type="checkbox" name="shared" aria-describedby="id_shared_help" id="id_shared">
|
||||
<i class="form-icon"></i>
|
||||
<label for="id_shared">Share</label>
|
||||
</div>
|
||||
""",
|
||||
html,
|
||||
count=1,
|
||||
)
|
||||
@@ -231,10 +232,10 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
html = response.content.decode()
|
||||
self.assertInHTML(
|
||||
"""
|
||||
<div class="form-input-hint">
|
||||
Share this bookmark with other registered users.
|
||||
</div>
|
||||
""",
|
||||
<div id="id_shared_help" class="form-input-hint">
|
||||
Share this bookmark with other registered users.
|
||||
</div>
|
||||
""",
|
||||
html,
|
||||
)
|
||||
|
||||
@@ -245,10 +246,10 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
html = response.content.decode()
|
||||
self.assertInHTML(
|
||||
"""
|
||||
<div class="form-input-hint">
|
||||
Share this bookmark with other registered users and anonymous users.
|
||||
</div>
|
||||
""",
|
||||
<div id="id_shared_help" class="form-input-hint">
|
||||
Share this bookmark with other registered users and anonymous users.
|
||||
</div>
|
||||
""",
|
||||
html,
|
||||
)
|
||||
|
||||
@@ -265,7 +266,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
html = response.content.decode()
|
||||
|
||||
self.assertInHTML(
|
||||
'<input type="checkbox" name="unread" id="id_unread">',
|
||||
'<input type="checkbox" name="unread" id="id_unread" aria-describedby="id_unread_help">',
|
||||
html,
|
||||
)
|
||||
|
||||
@@ -277,6 +278,6 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
html = response.content.decode()
|
||||
|
||||
self.assertInHTML(
|
||||
'<input type="checkbox" name="unread" id="id_unread" checked="">',
|
||||
'<input type="checkbox" name="unread" id="id_unread" checked="" aria-describedby="id_unread_help">',
|
||||
html,
|
||||
)
|
||||
|
Reference in New Issue
Block a user