Skip to content

fix #8272: bug in onSpaceKey with shift selection in PickList#8273

Merged
melloware merged 3 commits intoprimefaces:masterfrom
emmanuel-ferdman:master
Sep 8, 2025
Merged

fix #8272: bug in onSpaceKey with shift selection in PickList#8273
melloware merged 3 commits intoprimefaces:masterfrom
emmanuel-ferdman:master

Conversation

@emmanuel-ferdman
Copy link
Contributor

@emmanuel-ferdman emmanuel-ferdman commented Sep 7, 2025

Fix #8272.

PR Summary

This small PR handles a bug in onSpaceKey with shift selection in PickList.

Steps to reproduce the behavior

I have prepared a minimal demo:

import React, { useState, useMemo } from "react";
import { PickList } from "primereact/picklist";

export default function VirtualScrollDemo() {
  const allItems = useMemo(
    () =>
      Array.from({ length: 30 }, (_, i) => ({
        id: i + 1,
        name: `City #${i + 1}`,
      })),
    []
  );

  const [source, setSource] = useState(allItems.slice(0, 20));
  const [target, setTarget] = useState(allItems.slice(20));

  const onChange = (e) => {
    setSource(e.source);
    setTarget(e.target);
  };

  const itemTemplate = (item) => <div>{item.name}</div>;

  return (
    <div className="card" style={{ maxWidth: 900, margin: "2rem auto" }}>
      <h3>PickList – Keyboard Accessibility Demo</h3>
      <PickList
        dataKey="id"
        source={source}
        target={target}
        itemTemplate={itemTemplate}
        onChange={onChange}
        sourceHeader="Available"
        targetHeader="Selected"
        showSourceControls
        showTargetControls
        showSourceFilter
        showTargetFilter
        filterBy="name"
        metaKeySelection={false}
        breakpoint="768px"
        sourceStyle={{ height: "20rem" }}
        targetStyle={{ height: "20rem" }}
      />
    </div>
  );
}
  1. Run the demo.
  2. Focus the left (Available) list.
  3. Select one item with Enter or Space.
  4. Move focus with the arrow keys to another item further down.
  5. Press Shift + Space to select a range.

It will fail with runtime errors.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@melloware melloware changed the title fix: bug in onSpaceKey with shift selection in PickList fix #8272: bug in onSpaceKey with shift selection in PickList Sep 7, 2025
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@melloware
Copy link
Member

I think you need to run npm run format

@emmanuel-ferdman
Copy link
Contributor Author

emmanuel-ferdman commented Sep 8, 2025

@melloware I did ran npm run format on the files my PR change, but it complains on other non-related files. Do you want me to upload them as part of the PR?

@melloware
Copy link
Member

yes please!

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@emmanuel-ferdman
Copy link
Contributor Author

@melloware sure, updated. thanks for the review!

@melloware melloware merged commit 754439d into primefaces:master Sep 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PickList: Shift+Space range selection causes runtime error

2 participants

Comments