Keep a button at its label's width in a stack and a form
<x-stack> stretches its children across by default and <x-form> is a one-track grid, so a button written directly in either drew as a full-width pill. M3 keeps a button's width "dynamic to fit label" and says not to "stretch buttons into long flat shapes on large windows". A button there now sits at the start edge at its own width; a stack aligned start, centre or end is untouched, and an application's own width still wins (a cap on the button itself was rejected for exactly that: it would have limited an app's inline-size, which CascadeTest guards). Chromium test in both directions, failing without the rules. Decided with the user (plan step 46). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
f5f040516e
commit
92d3d761f3
@@ -72,6 +72,29 @@ it('spaces a stack with its token, never with its parent\'s, and hides it from a
|
||||
->assertScript(layoutStyle('#hidden-from', 'display')." === 'none'");
|
||||
});
|
||||
|
||||
it('keeps a button at its label\'s width in a stretched stack and a form, where the rest stretch', function () {
|
||||
// M3: keep a button's width "dynamic to fit label"; don't "stretch buttons into long flat shapes
|
||||
// on large windows". An application's own width still wins, and a centred stack centres it.
|
||||
$body = '<style>.probe-full { inline-size: 100%; }</style>'
|
||||
.'<x-stack id="stack" gap="space200" style="inline-size: 600px"><p id="stack-field">Name</p><x-button label="Save" id="stack-save" /><x-button label="Wide" class="probe-full" id="stack-wide" /></x-stack>'
|
||||
.'<x-stack id="centred" align="center" style="inline-size: 600px"><x-button label="Save" id="centred-save" /></x-stack>'
|
||||
.'<x-form id="form" style="inline-size: 600px"><x-input label="Name" /><x-button label="Go" id="form-go" /></x-form>';
|
||||
|
||||
layoutPage($body, 1280)
|
||||
->assertScript(layoutRect('#stack-field', 'width').' === 600')
|
||||
->assertScript(layoutRect('#stack-save', 'width').' < 200')
|
||||
->assertScript(layoutRect('#stack-save', 'left').' === '.layoutRect('#stack', 'left'))
|
||||
->assertScript(layoutRect('#stack-wide', 'width').' === 600')
|
||||
->assertScript('Math.abs(('.layoutRect('#centred-save', 'left').' + '.layoutRect('#centred-save', 'right').') / 2 - ('.layoutRect('#centred', 'left').' + '.layoutRect('#centred', 'right').') / 2) <= 1')
|
||||
->assertScript(layoutRect('#form-go', 'width').' < 200')
|
||||
->assertScript(layoutRect('#form-go', 'left').' === '.layoutRect('#form', 'left'));
|
||||
|
||||
// In a right-to-left document the start edge is the right.
|
||||
layoutPage($body, 1280, 900, 'rtl')
|
||||
->assertScript(layoutRect('#stack-save', 'right').' === '.layoutRect('#stack', 'right'))
|
||||
->assertScript(layoutRect('#form-go', 'right').' === '.layoutRect('#form', 'right'));
|
||||
});
|
||||
|
||||
it('stacks a row below its breakpoint and lays it side by side from it', function () {
|
||||
$body = '<x-row id="row" gap="space200" stack-below="medium"><span>One</span><span>Two</span></x-row>'
|
||||
.'<x-row id="aligned" align="start" stack-below="medium"><span>One</span></x-row>'
|
||||
|
||||
Reference in New Issue
Block a user