Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML Reporter: Fix bugs and improve usability of module filter menu
== Background == As part of fixing #1664, I found that the minimal patch of simply appending the module HTML on focus, no longer worked correctly in certain edge cases due to various refactors that took place since. This commit is the prep work to make the code simpler again, which then makes fixing #1664 really simple. I also fixed numerous bugs I found along the way, and improved the usability in a couple of ways. == Fix bugs == Most of these are specific to a narrow viewport, such as the iframe on the https://qunitjs.com homepage! * Dropdown menu was forced to 400px min-width, causing overflow on narrow viewports. Fixed for modern browsers by limiting min-width to 80vw. * The dropdown menu was positioned too high in narrow viewports. The position was based on `top: 50%; margin-top: 0.8em;`, which approximated "1 line-height from the top". This worked in most viewports, where the dropdown label and input render next to each other. However, in narrow viewports, they wrap are render below each other, and "1 line from the top" is then overlapping half-way through the input field. Fixed by positioning the menu at `top: 100%` instead, which is always below the input field. * The dropdown "arrow" icon was dislodged from the input field in narrow viewports due to being positioned absolutely on the right edge of the parent `<form>` and `<label>`. These are inline-block, which automatically follows the needed width, except when children wrap over multiple lines, then it reports its width as 100% even if there isn't anything in that space. Fixed by giving the parent element `text-align: right;` so that the dropdown menu and input field start from the right even in narrow viewports. On wider viewports this was already accomodated by `float: right;` for the then-single-line element. * Dropdown items had `text-overflow: ellipsis;` but this did not work in practice because it was applied to the `<li>` element instead of the `<label>` where the text resides. The second reason is that the dropdown menu did not have a maximum width, which meant longer module names resulted in the menu getting wider instead of the options being trimmed with ellipsis. This is good and desirable when there is sufficient space. Fixed by seting a liberal max-width, and moving overflow to the `<label>` element, which the ellipsis will appear as-needed. * There was an uncoloured padding between the line that divided the dropdown actions from the dropdown list, and the first selected item's background color. Fixed by removing padding from `#qunit-modulefilter-dropdown-list`. == Usability improvements == * When searching for a module, selecting it, and then searching for something else; previously the only indication of what you selected so far was the "placeholder" of the input field. Apart from being cropped and thus not showing most of the info, this was by definition not visible when actually using the filter to search. It was only shown when not using the filter. Get rid of this placeholder, and instead hoist the selected modules to the top of the results, shown always, even if they don't match. To ensure a retention of vision and ofer an easy way to undo accidental clicks, we only hoist options when re-rendering the dropdown (e.g. after deciding to refine or change your search). When the results are idle, clicks simply toggle the options in their current position. * Remove display toggling of the Reset/Apply buttons. Let these always be visible, with "Apply" always available, and the "Reset" button disabled when the selection is identical to the last-used (same as before). * Replace the "All modules" checkbox with a "Select none" button, and for the common case where this is functionally identical to the "Reset" button, hide it to reduce clutter. * Add tooltips to buttons to clarify their meaning. * Add proper button styles, including high-contrast border and hover/active/disabled styles. * For most viewports (wider than 350px) remove the reserved space for dropdown action buttons, and instead float them to the side and overlap the right side of the first dropdown result. == Remove == Unused code: ``` #qunit-modulefilter-dropdown a { color: inherit; text-decoration: none; } ``` Originally added in d14107a for the "All modules" action, which was an anchor link at the time. This hasn't been the case of a while.
- Loading branch information