Skip to content

A static list box is drawn as a drop-down showing one option instead of rows of options #440

Closed

Description

@jakejackson1

With useActiveForms off, a list box (a <select> with size of 2 or more, or multiple) is drawn as a drop-down. The box is size rows tall, but it shows one option with a ▼ button beside it. Browsers draw a list box as rows of options, with the selected ones highlighted and no arrow.

$mpdf = new \Mpdf\Mpdf(['useActiveForms' => false]);
$mpdf->WriteHTML('<form><select name="fruit" size="4" multiple>
	<option>Apple</option>
	<option selected>Banana</option>
	<option>Cherry</option>
	<option selected>Damson</option>
	<option>Elder</option>
</select></form>');

On gravitypdf the page shows a four-row-tall box. It holds "Damson", centred vertically, beside a four-row-tall ▼ button. "Banana" is not shown at all.

Cause.

  • Form::print_ob_select()'s static branch has one drawing for every select: a Cell() with the selected text, then the arrow cell. It never looks at size or multiple.
  • Tag\Select::close() passes only one string, selectoption['SELECTED']. Tag\Option::open() resets it for each selected option, so the last selected option wins, or the first option when none is selected.
  • The static width is measured from that one string (GetStringWidth($texto)). Active forms measure the widest option (MAXWIDTH), so a list box is also narrower than its longest option.

Expected. When a static select is a list box (the same test the active path uses since #419: multiple, or size of 2 or more):

The items array is already in $objattr in both modes, so the static branch has what it needs. Its rows and clip should follow the fix for #426, so the two modes agree.

Why it matters more now.

This changes how existing documents look and may change their layout (the width), so the PR needs an upgrade note. mpdf/mpdf development has the same code.

Found by the agents working on #425 and #400.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcreate-upstream-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions