forked from wagtail/wagtail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix filters from being removed when searching
Tippy unmounts its popper element from the DOM on hide, which means that the filter fields get detached from the form. As a result, when performing a search (which means the filters popup is closed), any filters that have been applied will be lost. The issue does not occur the other way around (filtering after search) because the filter fields will still be in the DOM (as the popup is open while you're applying the filters). Unfortunately, Tippy does not offer a built-in option to keep the popper mounted in the DOM when it's hidden. As a workaround, use Tippy's hooks to re-append the popper to the DOM. - onCreate: ensure the popper element is mounted even when the tippy was just created (normally it's only mounted when shown). This is useful to keep the filters when searching after a full-page refresh (e.g. after navigating to the next page in pagination). - onHidden: ensure the popper is still mounted, to solve the main issue - onShow: remove the hidden attribute and let tippy move the popper element as necessary (though usually this isn't necessary, because we remount it in the same position (the controller's element). The 'hidden' attribute shouldn't cause any issues here as Tippy doesn't use it. Without it, the solution still works because Tippy uses CSS to make the element invisible. However, the complete CSS doesn't get applied until the tippy is shown at least once. This means on initial load with the onCreate hook, the tippy will take up the space while being invisible. Using the attribute fixes it (and display:none probably would too). This behaviour can be enabled using the newly-added DropdownController value 'keepMounted'.
- Loading branch information
Showing
3 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters