fix(pds-multiselect): add csrf token support and fix selected items d…#654
fix(pds-multiselect): add csrf token support and fix selected items d…#654QuintonJason merged 5 commits intomainfrom
Conversation
…isplay - Add csrf-token prop with automatic meta tag detection - Fix selected items not displaying after tag creation - Fix initial render with async-url showing empty selections - Fix duplicate items in pdsMultiselectChange event - Improve syncSelectedItems to preserve items before async data loads
✅ Deploy Preview for pine-design-system ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@coderabbitai review this pr |
|
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughIntroduced an optional 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@libs/core/src/components/pds-multiselect/pds-multiselect.tsx`:
- Around line 522-535: The fetch code always sets 'Content-Type':
'application/json' which causes CORS preflights for GET; change the headers
construction in the method that builds the fetch options (references: csrfToken,
headers, this.asyncMethod, abortController, and the fetch(...) call) so that
'Content-Type' is only added when the request has a body (e.g., this.asyncMethod
!== 'GET' or when body !== undefined), keep X-CSRF-Token logic unchanged, and
ensure POST paths (the code around lines 608-616) still include 'Content-Type'
for JSON requests.
- Around line 225-229: The current initial async fetch unconditionally runs when
asyncUrl is set, using this.fetchOptions('', 1) even if consumers provided
external options; update the guard in the component so it only calls
fetchOptions when asyncUrl is set AND there are no externally supplied options —
e.g. check this.options (or whatever prop holds externally managed options) and
skip the fetch if that array is non-empty; modify the conditional around
this.fetchOptions to require this.asyncUrl && this.value.length > 0 &&
this.internalOptions.length === 0 && (!this.options || this.options.length ===
0) so externally managed options prevent the network request.
…isplay - Add csrf-token prop with automatic meta tag detection - Fix selected items not displaying after tag creation - Fix initial render with async-url showing empty selections - Fix duplicate items in pdsMultiselectChange event - Improve syncSelectedItems to preserve items before async data loads
|
@coderabbitai review this pr |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@libs/core/src/components/pds-loader/readme.md`:
- Around line 36-38: The markdown list items for pds-button, pds-combobox and
pds-multiselect use a leading space before the dash which triggers markdownlint
MD007; either remove the leading space so each line starts with "-" (e.g. "-
[pds-button](../pds-button)") or, if the file is truly auto-generated, add a
linter suppression for MD007 at the top of the generated file (or update the
generator) so the rule is ignored for this file.
| - [pds-button](../pds-button) | ||
| - [pds-combobox](../pds-combobox) | ||
| - [pds-multiselect](../pds-multiselect) |
There was a problem hiding this comment.
Markdown list indentation warning flagged by linter.
Lines 36-38 use leading space indentation ( - [item]) which triggers markdownlint MD007 warnings expecting no indentation. However, this file appears to be auto-generated (per "Auto Generated Below" comment), so manual fixes may be overwritten by the generator.
If this formatting is intentional or controlled by the generator, consider suppressing the lint rule for this file. Otherwise, remove the leading space:
Suggested fix
-- - [pds-button](../pds-button)
-- - [pds-combobox](../pds-combobox)
-- - [pds-multiselect](../pds-multiselect)
+- [pds-button](../pds-button)
+- [pds-combobox](../pds-combobox)
+- [pds-multiselect](../pds-multiselect)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - [pds-button](../pds-button) | |
| - [pds-combobox](../pds-combobox) | |
| - [pds-multiselect](../pds-multiselect) | |
| - [pds-button](../pds-button) | |
| - [pds-combobox](../pds-combobox) | |
| - [pds-multiselect](../pds-multiselect) |
🧰 Tools
🪛 markdownlint-cli2 (0.20.0)
[warning] 36-36: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
[warning] 37-37: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
[warning] 38-38: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
🤖 Prompt for AI Agents
In `@libs/core/src/components/pds-loader/readme.md` around lines 36 - 38, The
markdown list items for pds-button, pds-combobox and pds-multiselect use a
leading space before the dash which triggers markdownlint MD007; either remove
the leading space so each line starts with "-" (e.g. "-
[pds-button](../pds-button)") or, if the file is truly auto-generated, add a
linter suppression for MD007 at the top of the generated file (or update the
generator) so the rule is ignored for this file.
pixelflips
left a comment
There was a problem hiding this comment.
Should we add a mention of this on the docs page, otherwise LGTM!
Description
Fixes multiple issues in
pds-multiselectrelated to CSRF token handling, async data loading, and selected items display.Issues Fixed
csrf-tokenprop or automatic detection from<meta name="csrf-token">tagasync-urland preselected values now displays selections immediately (as placeholders until async data loads)pdsMultiselectChangeevent no longer emits duplicate itemsType of change
Implementation Details
CSRF Token Support
csrf-tokenprop<meta name="csrf-token">if prop not providedX-CSRF-Tokenheader for all async requestsSelected Items Fix
syncSelectedItems()to preserve items before async data loadstoggleOption()to always sync before emitting events (eliminates duplicates)How Has This Been Tested?
Test Configuration:
Console verification: All
pdsMultiselectChangeevents showedhasDuplicates: falsethroughout testing.Checklist: