Skip to content

Commit

Permalink
feat: Style add tags widget + staged tags
Browse files Browse the repository at this point in the history
Also clear search term whenever tags are staged/cancelled
  • Loading branch information
yusuf-musleh committed Mar 3, 2024
1 parent 5387893 commit 440969a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/content-tags-drawer/ContentTagsCollapsible.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@ const ContentTagsCollapsible = ({
}, 500); // Perform search after 500ms

const handleSearchChange = React.useCallback((value, { action }) => {
if (action === 'input-change') {
if (action === 'input-blur') {
// Cancel/clear search if focused away from select input
handleSearch.cancel();
setSearchTerm('');
} else if (action === 'input-change') {
if (value === '') {
// No need to debounce when search term cleared. Clear debounce function
handleSearch.cancel();
Expand Down Expand Up @@ -311,12 +315,14 @@ const ContentTagsCollapsible = ({
commitStagedTags();
handleStagedTagsMenuChange([]);
selectRef.current?.blur();

Check failure on line 317 in src/content-tags-drawer/ContentTagsCollapsible.jsx

View workflow job for this annotation

GitHub Actions / tests

Property 'blur' does not exist on type 'never'.
}, [commitStagedTags, handleStagedTagsMenuChange, selectRef]);
setSearchTerm('');
}, [commitStagedTags, handleStagedTagsMenuChange, selectRef, setSearchTerm]);

const handleCancelStagedTags = React.useCallback(() => {
handleStagedTagsMenuChange([]);
selectRef.current?.blur();

Check failure on line 323 in src/content-tags-drawer/ContentTagsCollapsible.jsx

View workflow job for this annotation

GitHub Actions / tests

Property 'blur' does not exist on type 'never'.
}, [handleStagedTagsMenuChange, selectRef]);
setSearchTerm('');
}, [handleStagedTagsMenuChange, selectRef, setSearchTerm]);

return (
<div className="d-flex">
Expand All @@ -337,7 +343,7 @@ const ContentTagsCollapsible = ({
placeholder={intl.formatMessage(messages.collapsibleAddTagsPlaceholderText)}
isSearchable
className="d-flex flex-column flex-fill"
classNamePrefix="react-select"
classNamePrefix="react-select-add-tags"
onInputChange={handleSearchChange}
onChange={handleStagedTagsMenuChange}
components={{
Expand Down
20 changes: 20 additions & 0 deletions src/content-tags-drawer/ContentTagsCollapsible.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,23 @@
background-color: transparent;
color: $gray-300 !important;
}

.react-select-add-tags__control {
border-radius: 0 !important;
}

.react-select-add-tags__control--is-focused {
border-color: black !important;
box-shadow: 0 0 0 1px black !important;
}

.react-select-add-tags__multi-value__remove {
padding-right: 7px !important;
padding-left: 7px !important;
border-radius: 0 3px 3px 0;

&:hover {
background-color: black !important;
color: white !important;
}
}

0 comments on commit 440969a

Please sign in to comment.