diff --git a/src/pattern-library/components/patterns/prototype/SelectPage.tsx b/src/pattern-library/components/patterns/prototype/SelectPage.tsx index d450c819f..d035d94fd 100644 --- a/src/pattern-library/components/patterns/prototype/SelectPage.tsx +++ b/src/pattern-library/components/patterns/prototype/SelectPage.tsx @@ -387,6 +387,33 @@ export default function SelectPage() { + + + + Determines if the listbox should be rendered using the{' '} + + popover API + + . It{"'"}s mainly used as a test seam, but can help explicitly + disabling this behavior if needed. + + + boolean + + + true if the browser supports [popover] + . Otherwise it is false + + + + @@ -405,30 +432,37 @@ export default function SelectPage() { - + - Determines if the listbox should be rendered using the{' '} - - popover API - - . It{"'"}s mainly used as a test seam, but can help explicitly - disabling this behavior if needed. + Determines the behavior of the listbox options when their + content is larger than the listbox. +
    +
  • + {"'truncate'"}: Text will use one line and be + truncated with an ellipsis. +
  • +
  • + {"'wrap'"}: Text will span multiple lines if + needed, ensuring all content is visible. +
  • +
- boolean + {"'truncate' | 'wrap'"} - true if the browser supports [popover] - . Otherwise it is false + {"'truncate'"}
+
diff --git a/src/pattern-library/examples/select-truncate-listbox.tsx b/src/pattern-library/examples/select-truncate-listbox.tsx new file mode 100644 index 000000000..f38390ac3 --- /dev/null +++ b/src/pattern-library/examples/select-truncate-listbox.tsx @@ -0,0 +1,51 @@ +import { useId, useState } from 'preact/hooks'; + +import { Select } from '../..'; + +const items = [ + { + id: '1', + name: 'All students - content is very long and will not fit the listbox', + }, + { + id: '2', + name: 'Albert Banana - content is very long and will not fit the listbox', + }, + { + id: '3', + name: 'Bernard California - content is very long and will not fit the listbox', + }, + { + id: '4', + name: 'Cecelia Davenport - content is very long and will not fit the listbox', + }, + { + id: '5', + name: 'Doris Evanescence - content is very long and will not fit the listbox', + }, +]; + +export default function App() { + const [value, setSelected] = useState<{ id: string; name: string }>(); + const selectId = useId(); + + return ( +
+ + +
+ ); +} diff --git a/src/pattern-library/examples/select-wrap-listbox.tsx b/src/pattern-library/examples/select-wrap-listbox.tsx new file mode 100644 index 000000000..a7a21bc5f --- /dev/null +++ b/src/pattern-library/examples/select-wrap-listbox.tsx @@ -0,0 +1,51 @@ +import { useId, useState } from 'preact/hooks'; + +import { Select } from '../..'; + +const items = [ + { + id: '1', + name: 'All students - content is very long and will not fit the listbox', + }, + { + id: '2', + name: 'Albert Banana - content is very long and will not fit the listbox', + }, + { + id: '3', + name: 'Bernard California - content is very long and will not fit the listbox', + }, + { + id: '4', + name: 'Cecelia Davenport - content is very long and will not fit the listbox', + }, + { + id: '5', + name: 'Doris Evanescence - content is very long and will not fit the listbox', + }, +]; + +export default function App() { + const [value, setSelected] = useState<{ id: string; name: string }>(); + const selectId = useId(); + + return ( +
+ + +
+ ); +}