feat(places): add a place straight into the day that is open

The places pool sits one click away from the plan, and a place you already know
belongs to today had to go through the day picker afterwards to get there. With
a day open, the add button splits: the left half still opens an empty form, the
right half opens one that assigns the place to that day on save.

The plumbing was already there. placeFormDayId has assigned a freshly created
place to a day since #1998; nothing in the places rail ever set it.

The main label shortens to "New place" while the split is out, so both buttons
fit side by side in the rail without either one truncating. The second button
stays mounted and collapsed rather than unmounted, so it has something to
animate out of: width, padding and opacity over 180ms, and nothing at all under
prefers-reduced-motion. Collapsed it is also out of the tab order and hidden
from screen readers, because a zero-width button is still focusable otherwise.

Both columns of the place form are 320px now. Two panels of different widths
flanking one form read as a mistake rather than as a hierarchy, and neither of
them is the more important one.
This commit is contained in:
Maurice
2026-09-08 17:35:40 +02:00
committed by Maurice
parent 900e4806ad
commit 9fa0ceaf49
29 changed files with 172 additions and 17 deletions
@@ -88,6 +88,39 @@ describe('PlacesSidebar', () => {
expect(onAddPlace).toHaveBeenCalled();
});
/**
* The split add button (a day is open).
*
* Two buttons rather than one, because the pool sits a click away from the plan
* and a place you already know belongs to today should not need a second trip
* through the day picker. The second one stays mounted and collapsed so it has
* something to animate out of.
*/
it('FE-COMP-PLACES-005b: with no day open there is one add button, at full length', () => {
render(<PlacesSidebar {...defaultProps} selectedDayId={null} onAddPlaceToSelectedDay={vi.fn()} />);
expect(screen.getAllByText(/Add Place\/Activity/i).length).toBeGreaterThan(0);
expect(screen.queryByText('New place')).not.toBeInTheDocument();
// Present in the DOM so it can animate, but out of reach until a day is open.
const quick = screen.getByTestId('add-place-to-day');
expect(quick).toHaveAttribute('aria-hidden', 'true');
expect(quick).toHaveAttribute('tabindex', '-1');
});
it('FE-COMP-PLACES-005c: an open day splits the button and shortens the main label', async () => {
const user = userEvent.setup();
const onAddPlaceToSelectedDay = vi.fn();
render(<PlacesSidebar {...defaultProps} selectedDayId={7} onAddPlaceToSelectedDay={onAddPlaceToSelectedDay} />);
// Shortened so both fit side by side without either truncating.
expect(screen.getByText('New place')).toBeInTheDocument();
const quick = screen.getByTestId('add-place-to-day');
expect(quick).toHaveAttribute('tabindex', '0');
await user.click(quick);
expect(onAddPlaceToSelectedDay).toHaveBeenCalled();
});
it('FE-COMP-PLACES-006: clicking a place calls onPlaceClick with place id', async () => {
const user = userEvent.setup();
const onPlaceClick = vi.fn();