Skip to content

Commit

Permalink
fix(bug): useTextSelection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-ovo committed Jun 25, 2023
1 parent 5da4cc4 commit 60b6069
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/hooks/src/useCookieState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function useCookieState(cookieKey: string, options: Options = {}) {
newValue: State | ((prevState: State) => State),
newOptions: Cookies.CookieAttributes = {},
) => {
const { defaultValue, ...restOptions } = { ...options, ...newOptions };
const { ...restOptions } = { ...options, ...newOptions };
const value = isFunction(newValue) ? newValue(state) : newValue;

setState(value);
Expand Down
3 changes: 3 additions & 0 deletions packages/hooks/src/useTextSelection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ function useTextSelection(target?: BasicTarget<Document | Element>): State {

// 任意点击都需要清空之前的 range
const mousedownHandler = (e) => {
// 如果是鼠标右键需要跳过 这样选中的数据就不会被清空
if (e.button === 2) return;

if (!window.getSelection) return;
if (stateRef.current.text) {
setState({ ...initState });
Expand Down

0 comments on commit 60b6069

Please sign in to comment.