Skip to content

Remove links from checkbox labels. #8667

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions app/lib/frontend/templates/views/pkg/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,9 @@ d.Node _tagBasedCheckbox({
required String title,
}) {
final tag = '$tagPrefix:$tagValue';
final toggledSearchForm = searchForm.toggleRequiredTag(tag);
return _formLinkedCheckbox(
id: 'search-form-checkbox-$tagPrefix-$tagValue',
label: label,
toggledSearchForm: toggledSearchForm,
isChecked: searchForm.parsedQuery.tagsPredicate.isRequiredTag(tag),
isIndeterminate: searchForm.parsedQuery.tagsPredicate.isProhibitedTag(tag),
tag: tag,
Expand All @@ -241,7 +239,6 @@ d.Node _tagBasedCheckbox({
d.Node _formLinkedCheckbox({
required String id,
required String label,
required SearchForm toggledSearchForm,
required bool isChecked,
bool isIndeterminate = false,
String? tag,
Expand All @@ -256,14 +253,12 @@ d.Node _formLinkedCheckbox({
child: material.checkbox(
id: id,
label: label,
labelNodeContent: (label) => d.a(
href: toggledSearchForm.toSearchLink(),
labelNodeContent: (label) => d.span(
text: label,
attributes: {
if (action != null) 'data-action': action,
if (tag != null) 'data-tag': tag,
},
rel: 'nofollow',
),
checked: isChecked,
indeterminate: isIndeterminate,
Expand Down
30 changes: 15 additions & 15 deletions app/test/frontend/golden/pkg_index_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-android">
<a href="/packages?q=sdk%3Adart+platform%3Aandroid" rel="nofollow" data-action="filter-platform-android" data-tag="platform:android">Android</a>
<span data-action="filter-platform-android" data-tag="platform:android">Android</span>
</label>
</div>
</div>
Expand All @@ -155,7 +155,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-ios">
<a href="/packages?q=sdk%3Adart+platform%3Aios" rel="nofollow" data-action="filter-platform-ios" data-tag="platform:ios">iOS</a>
<span data-action="filter-platform-ios" data-tag="platform:ios">iOS</span>
</label>
</div>
</div>
Expand All @@ -172,7 +172,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-linux">
<a href="/packages?q=sdk%3Adart+platform%3Alinux" rel="nofollow" data-action="filter-platform-linux" data-tag="platform:linux">Linux</a>
<span data-action="filter-platform-linux" data-tag="platform:linux">Linux</span>
</label>
</div>
</div>
Expand All @@ -189,7 +189,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-macos">
<a href="/packages?q=sdk%3Adart+platform%3Amacos" rel="nofollow" data-action="filter-platform-macos" data-tag="platform:macos">macOS</a>
<span data-action="filter-platform-macos" data-tag="platform:macos">macOS</span>
</label>
</div>
</div>
Expand All @@ -206,7 +206,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-web">
<a href="/packages?q=sdk%3Adart+platform%3Aweb" rel="nofollow" data-action="filter-platform-web" data-tag="platform:web">Web</a>
<span data-action="filter-platform-web" data-tag="platform:web">Web</span>
</label>
</div>
</div>
Expand All @@ -223,7 +223,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-windows">
<a href="/packages?q=sdk%3Adart+platform%3Awindows" rel="nofollow" data-action="filter-platform-windows" data-tag="platform:windows">Windows</a>
<span data-action="filter-platform-windows" data-tag="platform:windows">Windows</span>
</label>
</div>
</div>
Expand All @@ -248,7 +248,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-sdk-dart">
<a href="/packages" rel="nofollow" data-action="filter-sdk-dart" data-tag="sdk:dart">Dart</a>
<span data-action="filter-sdk-dart" data-tag="sdk:dart">Dart</span>
</label>
</div>
</div>
Expand All @@ -265,7 +265,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-sdk-flutter">
<a href="/packages?q=sdk%3Adart+sdk%3Aflutter" rel="nofollow" data-action="filter-sdk-flutter" data-tag="sdk:flutter">Flutter</a>
<span data-action="filter-sdk-flutter" data-tag="sdk:flutter">Flutter</span>
</label>
</div>
</div>
Expand All @@ -290,7 +290,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-license-osi-approved">
<a href="/packages?q=sdk%3Adart+license%3Aosi-approved" rel="nofollow" data-action="filter-license-osi-approved" data-tag="license:osi-approved">OSI approved</a>
<span data-action="filter-license-osi-approved" data-tag="license:osi-approved">OSI approved</span>
</label>
</div>
</div>
Expand All @@ -315,7 +315,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-is-flutter-favorite">
<a href="/packages?q=sdk%3Adart+is%3Aflutter-favorite" rel="nofollow" data-action="filter-is-flutter-favorite" data-tag="is:flutter-favorite">Flutter Favorite</a>
<span data-action="filter-is-flutter-favorite" data-tag="is:flutter-favorite">Flutter Favorite</span>
</label>
</div>
</div>
Expand All @@ -332,7 +332,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-show-unlisted">
<a href="/packages?q=sdk%3Adart+show%3Aunlisted" rel="nofollow" data-action="filter-show-unlisted" data-tag="show:unlisted">Include unlisted</a>
<span data-action="filter-show-unlisted" data-tag="show:unlisted">Include unlisted</span>
</label>
</div>
</div>
Expand All @@ -349,7 +349,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-has-screenshot">
<a href="/packages?q=sdk%3Adart+has%3Ascreenshot" rel="nofollow" data-action="filter-has-screenshot" data-tag="has:screenshot">Has screenshot</a>
<span data-action="filter-has-screenshot" data-tag="has:screenshot">Has screenshot</span>
</label>
</div>
</div>
Expand All @@ -366,7 +366,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-is-dart3-compatible">
<a href="/packages?q=sdk%3Adart+is%3Adart3-compatible" rel="nofollow" data-action="filter-is-dart3-compatible" data-tag="is:dart3-compatible">Dart 3 compatible</a>
<span data-action="filter-is-dart3-compatible" data-tag="is:dart3-compatible">Dart 3 compatible</span>
</label>
</div>
</div>
Expand All @@ -383,7 +383,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-is-plugin">
<a href="/packages?q=sdk%3Adart+is%3Aplugin" rel="nofollow" data-action="filter-is-plugin" data-tag="is:plugin">Flutter plugin</a>
<span data-action="filter-is-plugin" data-tag="is:plugin">Flutter plugin</span>
</label>
</div>
</div>
Expand All @@ -400,7 +400,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-is-wasm-ready">
<a href="/packages?q=sdk%3Adart+is%3Awasm-ready" rel="nofollow" data-action="filter-is-wasm-ready" data-tag="is:wasm-ready">WASM ready</a>
<span data-action="filter-is-wasm-ready" data-tag="is:wasm-ready">WASM ready</span>
</label>
</div>
</div>
Expand Down
30 changes: 15 additions & 15 deletions app/test/frontend/golden/search_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-android">
<a href="/packages?q=platform%3Aandroid+foobar&amp;sort=top" rel="nofollow" data-action="filter-platform-android" data-tag="platform:android">Android</a>
<span data-action="filter-platform-android" data-tag="platform:android">Android</span>
</label>
</div>
</div>
Expand All @@ -156,7 +156,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-ios">
<a href="/packages?q=platform%3Aios+foobar&amp;sort=top" rel="nofollow" data-action="filter-platform-ios" data-tag="platform:ios">iOS</a>
<span data-action="filter-platform-ios" data-tag="platform:ios">iOS</span>
</label>
</div>
</div>
Expand All @@ -173,7 +173,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-linux">
<a href="/packages?q=platform%3Alinux+foobar&amp;sort=top" rel="nofollow" data-action="filter-platform-linux" data-tag="platform:linux">Linux</a>
<span data-action="filter-platform-linux" data-tag="platform:linux">Linux</span>
</label>
</div>
</div>
Expand All @@ -190,7 +190,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-macos">
<a href="/packages?q=platform%3Amacos+foobar&amp;sort=top" rel="nofollow" data-action="filter-platform-macos" data-tag="platform:macos">macOS</a>
<span data-action="filter-platform-macos" data-tag="platform:macos">macOS</span>
</label>
</div>
</div>
Expand All @@ -207,7 +207,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-web">
<a href="/packages?q=platform%3Aweb+foobar&amp;sort=top" rel="nofollow" data-action="filter-platform-web" data-tag="platform:web">Web</a>
<span data-action="filter-platform-web" data-tag="platform:web">Web</span>
</label>
</div>
</div>
Expand All @@ -224,7 +224,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-platform-windows">
<a href="/packages?q=platform%3Awindows+foobar&amp;sort=top" rel="nofollow" data-action="filter-platform-windows" data-tag="platform:windows">Windows</a>
<span data-action="filter-platform-windows" data-tag="platform:windows">Windows</span>
</label>
</div>
</div>
Expand All @@ -249,7 +249,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-sdk-dart">
<a href="/packages?q=sdk%3Adart+foobar&amp;sort=top" rel="nofollow" data-action="filter-sdk-dart" data-tag="sdk:dart">Dart</a>
<span data-action="filter-sdk-dart" data-tag="sdk:dart">Dart</span>
</label>
</div>
</div>
Expand All @@ -266,7 +266,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-sdk-flutter">
<a href="/packages?q=sdk%3Aflutter+foobar&amp;sort=top" rel="nofollow" data-action="filter-sdk-flutter" data-tag="sdk:flutter">Flutter</a>
<span data-action="filter-sdk-flutter" data-tag="sdk:flutter">Flutter</span>
</label>
</div>
</div>
Expand All @@ -291,7 +291,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-license-osi-approved">
<a href="/packages?q=license%3Aosi-approved+foobar&amp;sort=top" rel="nofollow" data-action="filter-license-osi-approved" data-tag="license:osi-approved">OSI approved</a>
<span data-action="filter-license-osi-approved" data-tag="license:osi-approved">OSI approved</span>
</label>
</div>
</div>
Expand All @@ -316,7 +316,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-is-flutter-favorite">
<a href="/packages?q=is%3Aflutter-favorite+foobar&amp;sort=top" rel="nofollow" data-action="filter-is-flutter-favorite" data-tag="is:flutter-favorite">Flutter Favorite</a>
<span data-action="filter-is-flutter-favorite" data-tag="is:flutter-favorite">Flutter Favorite</span>
</label>
</div>
</div>
Expand All @@ -333,7 +333,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-show-unlisted">
<a href="/packages?q=show%3Aunlisted+foobar&amp;sort=top" rel="nofollow" data-action="filter-show-unlisted" data-tag="show:unlisted">Include unlisted</a>
<span data-action="filter-show-unlisted" data-tag="show:unlisted">Include unlisted</span>
</label>
</div>
</div>
Expand All @@ -350,7 +350,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-has-screenshot">
<a href="/packages?q=has%3Ascreenshot+foobar&amp;sort=top" rel="nofollow" data-action="filter-has-screenshot" data-tag="has:screenshot">Has screenshot</a>
<span data-action="filter-has-screenshot" data-tag="has:screenshot">Has screenshot</span>
</label>
</div>
</div>
Expand All @@ -367,7 +367,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-is-dart3-compatible">
<a href="/packages?q=is%3Adart3-compatible+foobar&amp;sort=top" rel="nofollow" data-action="filter-is-dart3-compatible" data-tag="is:dart3-compatible">Dart 3 compatible</a>
<span data-action="filter-is-dart3-compatible" data-tag="is:dart3-compatible">Dart 3 compatible</span>
</label>
</div>
</div>
Expand All @@ -384,7 +384,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-is-plugin">
<a href="/packages?q=is%3Aplugin+foobar&amp;sort=top" rel="nofollow" data-action="filter-is-plugin" data-tag="is:plugin">Flutter plugin</a>
<span data-action="filter-is-plugin" data-tag="is:plugin">Flutter plugin</span>
</label>
</div>
</div>
Expand All @@ -401,7 +401,7 @@ <h3 class="search-form-section-header foldable-button">
<div class="mdc-checkbox__ripple"></div>
</div>
<label for="search-form-checkbox-is-wasm-ready">
<a href="/packages?q=is%3Awasm-ready+foobar&amp;sort=top" rel="nofollow" data-action="filter-is-wasm-ready" data-tag="is:wasm-ready">WASM ready</a>
<span data-action="filter-is-wasm-ready" data-tag="is:wasm-ready">WASM ready</span>
</label>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions pkg/web_app/lib/src/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ void _setEventsForSearchForm() {
// checking the checkbox will trigger a click on the link.
document.querySelectorAll('.search-form-linked-checkbox').forEach((e) {
final checkbox = e.querySelector('input');
final link = e.querySelector('a');
if (checkbox != null && link != null) {
final tag = link.dataset['tag'];
final action = link.dataset['action'];
final label = e.querySelector('[data-tag]');
if (checkbox != null && label != null) {
final tag = label.dataset['tag'];
final action = label.dataset['action'];
if (tag == null) return;

Future<void> handleClick(Event event) async {
Expand All @@ -84,7 +84,7 @@ void _setEventsForSearchForm() {
}

checkbox.onChange.listen(handleClick);
link.onClick.listen(handleClick);
label.onClick.listen(handleClick);
e.onClick.listen(handleClick);
}
});
Expand Down